Skip to main content
imporve title and formatting; clarify error code as people might search by it as well
Source Link

Import ofnumbers from CSV with OpenRead

I have tried to use OpenReadOpenRead for my application as it appears to be less of a burden on the memory.

I OpenReadOpenRead a .csv file to extract coordinates in the form {x,y} in the following way

    ClearAll[f];
f = OpenRead["mathfile.csv"];
g = ReadList[f, String, RecordLists -> True];
Close[f];

I can access each record seperately by just calling g[[1]]. However the format is not as numbers and so a function like ListPlot[g[[1]]] doesn't work.

If I use "Number" or "Real" as an option within ReadList I get an error code saying "invalid real number found when reading from 'f' .:

"Read:readn: Invalid real number found when reading from 'f'."

Using "String" or "Record" within ReadList doesn't cause a problem. However I would have to convert the "String""String" or "Record""Record" into a number format.

What am I doing wrong ? I would like to call g[[1]] and have the co-ordinate in a form that can be read by ListPlot

Thanks

Import of CSV with OpenRead

I have tried to use OpenRead for my application as it appears to be less of a burden on the memory.

I OpenRead a .csv file to extract coordinates in the form {x,y} in the following way

    ClearAll[f];
f = OpenRead["mathfile.csv"];
g = ReadList[f, String, RecordLists -> True];
Close[f];

I can access each record seperately by just calling g[[1]]. However the format is not as numbers and so a function like ListPlot[g[[1]]] doesn't work.

If I use "Number" or "Real" as an option within ReadList I get an error code saying "invalid real number found when reading from 'f' . Using "String" or "Record" within ReadList doesn't cause a problem. However I would have to convert the "String" or "Record" into a number format.

What am I doing wrong ? I would like to call g[[1]] and have the co-ordinate in a form that can be read by ListPlot

Thanks

Import numbers from CSV with OpenRead

I have tried to use OpenRead for my application as it appears to be less of a burden on the memory.

I OpenRead a .csv file to extract coordinates in the form {x,y} in the following way

ClearAll[f];
f = OpenRead["mathfile.csv"];
g = ReadList[f, String, RecordLists -> True];
Close[f];

I can access each record seperately by just calling g[[1]]. However the format is not as numbers and so a function like ListPlot[g[[1]]] doesn't work.

If I use "Number" or "Real" as an option within ReadList I get an error:

"Read:readn: Invalid real number found when reading from 'f'."

Using "String" or "Record" within ReadList doesn't cause a problem. However I would have to convert the "String" or "Record" into a number format.

What am I doing wrong ? I would like to call g[[1]] and have the co-ordinate in a form that can be read by ListPlot

Thanks

Bumped by Community user
Source Link
BRS
  • 41
  • 1

Import of CSV with OpenRead

I have tried to use OpenRead for my application as it appears to be less of a burden on the memory.

I OpenRead a .csv file to extract coordinates in the form {x,y} in the following way

    ClearAll[f];
f = OpenRead["mathfile.csv"];
g = ReadList[f, String, RecordLists -> True];
Close[f];

I can access each record seperately by just calling g[[1]]. However the format is not as numbers and so a function like ListPlot[g[[1]]] doesn't work.

If I use "Number" or "Real" as an option within ReadList I get an error code saying "invalid real number found when reading from 'f' . Using "String" or "Record" within ReadList doesn't cause a problem. However I would have to convert the "String" or "Record" into a number format.

What am I doing wrong ? I would like to call g[[1]] and have the co-ordinate in a form that can be read by ListPlot

Thanks