Problem with ReadList, record separator is not working

I have entries in a file with the following form:

3579038 2cc567cda3afd5e1d5406152e8ba77024c46ecda 2742564

4202599 093e88c26bd1637d12253115bd5a8a81531ba68f 2742821

3579039 2cc567cda3afd5e1d5406152e8ba77024c46ecda 2742821

214683 baf9b58d25683a4d2e85dd51894f3960722db807 2571212

438470 baf9b58d25683a4d2e85dd51894f3960722db807 2571212

742129 baf9b58d25683a4d2e85dd51894f3960722db807 2571212

743929 baf9b58d25683a4d2e85dd51894f3960722db807 2571212

The list has dimensions of [593000, 3] thus I am trying to open it with OpenRead and ReadList but for some unknown reason, it doesn't work. My code is:

openR = OpenRead[file];
readL = ReadList[openR, {Record, Record, Record}, RecordSeparators -> { ",", "\n"} ]


The result I get is :

{
{3800618, 73a607f272e9b4413553c749d94ef691be52a215, 2744667 3806136},
{73a607f272e9b4413553c749d94ef691be52a215, 2744667 4112812, 73a607f272e9b4413553c749d94ef691be52a215}....
}


As you see, it is skipping a record separators and thus every element is "delayed". The file is in CSV format.

• Cancan, can you post a few lines straight from your file? ReadList worked fine for me with the data you showed, but i suspect that you may have cleaned those up already. – MarcoB May 24 '15 at 21:34
• Are those curly brackets and the assignment also in the file? – Sjoerd C. de Vries May 24 '15 at 22:31
• @MarcoB: these are a few lines straight from my file 3579038 2cc567cda3afd5e1d5406152e8ba77024c46ecda 2742564 4202599 093e88c26bd1637d12253115bd5a8a81531ba68f 2742821 3579039 2cc567cda3afd5e1d5406152e8ba77024c46ecda 2742821 214683 baf9b58d25683a4d2e85dd51894f3960722db807 2571212 438470 baf9b58d25683a4d2e85dd51894f3960722db807 2571212 742129 baf9b58d25683a4d2e85dd51894f3960722db807 2571212 743929 baf9b58d25683a4d2e85dd51894f3960722db807 2571212 well, it is hard to see but there are actually 3 columns.. – Cancan May 25 '15 at 9:11
• @Cancan Yes, thank you. I added your data to your question. Please take a look at my answer below and let me know if it solves your problem. – MarcoB May 25 '15 at 9:14

I think you may just have your record separators set incorrectly. Note also that, if those lines are representative of the whole file, then your values are space-separated, rather than comma-separated as you seemed to suggest in your original post.

I copied those lines straight into a text file, then used ReadList to read them back in. I set the RecordSeparators to the following: any line terminator combination, or a single white space.

ReadList["cancan.txt", {Record, Record, Record},
RecordSeparators -> {"\n", "\r\n", "\r", " "}]

{
{"3579038", "2cc567cda3afd5e1d5406152e8ba77024c46ecda", "2742564"},
{"4202599", "093e88c26bd1637d12253115bd5a8a81531ba68f", "2742821"},
{"3579039", "2cc567cda3afd5e1d5406152e8ba77024c46ecda", "2742821"},
{"214683", "baf9b58d25683a4d2e85dd51894f3960722db807", "2571212"},
{"438470", "baf9b58d25683a4d2e85dd51894f3960722db807", "2571212"},
{"742129", "baf9b58d25683a4d2e85dd51894f3960722db807", "2571212"},
{"743929", "baf9b58d25683a4d2e85dd51894f3960722db807", "2571212"}
}


This should be what you wanted.

• Hi @MarcoB, it worked! thank you!! – Cancan May 28 '15 at 20:03
• @Cancan great! I'm glad to hear it worked! If you think that my answer solves your problem, I would appreciate it if you would consider accepting it. – MarcoB May 28 '15 at 20:40