Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When importing a csv file is there a way to set the delimiter. I have a csv that uses ";" as its delimiter.

I tried

 rd = import["/Users/rolfbosscha/Downloads/rsdata.csv"]
share|improve this question
1  
You can use ReadList which happens to be much faster than Import See for example mathematica.stackexchange.com/questions/35371/…. With only a slight modification: change "," to ";" under RecordSeperators –  RunnyKine Nov 19 '13 at 21:14
3  
Mathematica is case-sensitive: use Import, not import. –  m_goldberg Nov 19 '13 at 21:21

2 Answers 2

This seems to work:

Import["data.csv", "table", FieldSeparators -> ";"]
share|improve this answer

I may be mistaken here, but I don't think you can switch from the standard CSV definition (commas separate values) to the one you have (commas take the role of decimal points, and semicolons are used as value separator). A workaround might be to first import as text, switch the offending characters and import that.

As a demo I use ImportString here instead of Import, but it should work almost the same for Import too.

ImportString[
  StringReplace[ 
     ImportString["1,2;2;3;4.3\n2,3;4,5;6;7", "Text"], 
     {"," -> ".", ";" -> ","}
  ], 
  "CSV"
]

{{1.2, 2, 3, 4.3}, {2.3, 4.5, 6, 7}}

Replace the inner ImportString with

Import["/Users/rolfbosscha/Downloads/rsdata.csv", "Text"]

to work with your file. Note that you need to use "Text" instead of "CSV".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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