Reading csv files ignoring header info and text in between
Show older comments
HI,
I have two types of CSV files which i extract from a measurement instrument.
The first one(Dirty_Complex_Condensed.csv) , attached with this question has
- Header text data which i would like to ignore(lines 1-5)
- Some integers which i would like to not ignore(lines 6-34)
- Complex decimal data which i would like to not ignore(lines 21-35) or really need.(measurement)
The second one(Dirty_Supplement_Condensed.csv) also attached has
- Header text data which i would like to ignore(lines 1-5)
- Some integers which i would like to not ignore(lines 6-34) or really need(measurement)
- Header text data which i would like to ignore(lines 21-27)
- Some integer which i would like to not ignore(lines 9-34) and append to the earlier integer data read(lines 6-34).(measurement)
Also note that the location(line number) of these header and measurement data is not always constant because it depends on the type of conditions of the data being mesaured. So how do i take that consideration and make my code flexible so that i am not hard-coding the 'row' or 'line number' for different csv read in?
I am attaching 'Clean_Complex_Condensed.csv' and 'Clean_Supplement_Condensed.csv' for your reference on how i would like the data be eventually as i read them in. The number of rows in the imported 'Cleaned' version of the csv's should always be the same between the two files.
Currently, i am manually going in and deleting these header text data and then using 'csvread' command , but undoubtedly, this is too time consuming.
I have checked the following previous links which are relevent but not exactly or quite close to what am trying to accomplish here.
I guess the most powerful way is to use 'regex' but before i break my head further i wanted to know if any of the clever cogs MVPs /MathWorks staff had any fast and bright suggestions for a relatively simple question i have.
Thanks,
IP
Accepted Answer
More Answers (0)
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!