I have data files with the following form : “name of block 1”, then 3 columns of data, then two blank lines, then second block and repeat.
I attached an example of such a file to this post.
I would like to open this file in a notebook, and generate lists with it. The name of the lists should be the name of the blocks (one list per block), and their content should be : { {X1, Y1}, {X2, Y2}, …} such that Xi and Yi are the values in the two first columns of the blocks.
I know that should be feasible with the Import command, but I do not know exactly how…
This command returns a list with the elements of the file, and it works fine when I am working with files with just columns of data, without blocks or titles.
But here it does not work, because the software should detect each block of data thanks to the two line breaks between them… (I do not know the length of each block).
I do not want to create a huge list, mixing up all the data.
That is not part of the CSV specification I believe, it can only handle 2D data, not 3D as you want. However you can split the data in to blocks right?
fn = "exemple.csv";
data = Import[fn, "TSV"];
data = Split[data, # =!= {""} &]; (* split at empty row *)
data = DeleteCases[data, {{""}} | {""}, \[Infinity]] (* remove empty records *)
Now you have to replace -inf probably with something that is understood, similarly for nan…