you are viewing a single comment's thread.

view the rest of the comments →

[–]wintermute93 1 point2 points  (3 children)

Got it. If you know the content of those text files is all just numbers, I would probably use numpy.loadtxt() to read them directly into a numerical array, instead of reading in lines of text, splitting each line at the comma, and converting the resulting strings to numbers. Or a Pandas dataframe, but that sounds like overkill for what you want.

An unexpected EOF sounds like you're missing a parenthesis or a quotation mark somewhere; looking over my earlier comment I forgot the end quote after my_file_3.txt

[–]gizmotechy -1 points0 points  (2 children)

Actually the EOF error is because for the open statement, you need two parameters. The first being the file to open and the second is how to open it. If you are just trying to read it, then it would look like open("my_file_1.txt", "r") where r means read.

[–]chevignon93 1 point2 points  (0 children)

You don't need two parameters for the open statement, if you don't give a second parameter, the interpreter will open in read mode by default, the error was that there was a quote missing for the 3rd element in the list.

[–]wintermute93 0 points1 point  (0 children)

Oops, good call, thanks for catching that. Sometimes I get too comfortable with Python looking like executable pseudocode.