3
$\begingroup$

I would like to remove quotes around fields when importing a csv table. It should be simple, but I cannot find any answer.

My data is in the format {{r, t}, f[r, t]} and it is a table of a couple of thousand fields.

I have experimented with exporting as .data with option "Table" and then importing as "TSV", and with .csv and playing with "TextDelimiter" and "FieldSeparator". Even if the .csv file has no quotes around fields, they get it upon import.

I need to do an interpolation of the data and it does not work with the quotes that are applied.

Any comments on the proper procedure would be appreciated, i.e., if csv is not the most optimal way of exporting etc.

EDIT: While composing this post I discovered the .wdx format which works out of the box, but I am still interested in knowing what I was doing wrong about the .csv.

$\endgroup$
3
  • 1
    $\begingroup$ ToExpression@Import[]? $\endgroup$ – Feyre Jan 31 '17 at 12:37
  • $\begingroup$ See link $\endgroup$ – Gvxfjørt Jan 31 '17 at 12:47
  • $\begingroup$ Thanks for the link and the ToExpression[] / ToExpression@. I had already found the link but couldn't understand the syntax, which did not work out of the box. $\endgroup$ – Kaspar H Jan 31 '17 at 13:18
3
$\begingroup$

The answer, as given in comments by Feyre and Gavy, the way to avoid the double quotations is to import in the following way

importedTable = ToExpression[Import["file.csv"]]

or

importedTable = ToExpression@Import["file.csv"]

or to use another format, as I edited

Export["file.wdx"]
importedTable = Import["file.wdx"]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.