Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.3K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Import data from a text file?

Posted 9 years ago
Attachments:
4 Replies

Ok thank you for this model. I will need some time to understand your commands, and then we will see if it inspires me ^^

thanks again

> should detect each block of 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...

POSTED BY: Sander Huisman

Usually I am using this very simple method :

data = Import["/mypath"]

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.

What have you tried? I don't see your code. Have a look at the documentation: CSV and Import.

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard