# Mathematica - set end-of-line characters when importing

I have a plain text file of tab-separated values that was created on a Windows machine. I want to import it into Mathematica on a Mac.

rawdata = Import["filename.csv", "tsv"]


The output list has a blank list every other element. I think this is due to the old \r\n-vs-\n compatibility issue. How can I tell Import which convention the input file is using?

Edit: I should mention that I want to do this in a cross-platform way, because I'll probably be moving notebooks between Mac and Windows machines. So simply skipping every other element of the output list ([[1;2;-1]]) won't work.

Edit 2: This is what the file looks like when I open it in Emacs:

...
4.510000000000000E+008  -1.052316667849458E+002 -1.412043034275902E+002 ^M
4.515000000000000E+008  -1.159523802353636E+002 1.631532615796773E+002 ^M
...


The spaces between the fields are tabs. A moment's Googling tells me that ^M is a carriage return (\r). This fits my hypothesis that the Windows-based device is terminating lines with \r\n, and Mathematica is reading that as two new-lines. My question remains: How do I tell Import what EOL characters are in use in my file?

-

## migrated from stackoverflow.comJan 17 '13 at 16:48

This question came from our site for professional and enthusiast programmers.

Why the file name extension is .csv while the format of the file is TSV? The Import must not depend on this but it is strange. Which Mathematica version are you using? –  Alexey Popkov Jan 16 '13 at 17:37
@belisarius I did. @AlexeyPopkov it was generated by a scientific instrument, and that's the format it came in. csv files are just plain text anyway. –  poorsod Jan 16 '13 at 22:31
@poorsod - check the HEX of the end-of-line with an editor like Vim. Regular CSV end-of-line should be OdOa (as in CR/LF or \r\n). Perhaps you have something else. –  Chris Degnen Jan 17 '13 at 9:25
@ChrisDegnen, please see my edit. –  Benjamin Hodgson Jan 17 '13 at 17:46