Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Help with parsing a csv

Asked by Tony

Tony (view profile)

on 28 Mar 2013


I'm a fairly new user to MATLAB and programming. I need some help and guidance with the following problem.

I have a lot of csv files with only 1 line of data in each. The data in each csv looks like the following: 39605.000000,39605.333433,39605.333433,8.000000,0.000000,3.441000,4.239000,4.754000,5.179000

The first 5 columns looks like it is date/time related and the last 4 columns are the data values I need.

I am trying to create 4 new csv's from the 4 data values with the following format: '', data

Can anyone please help or provide me some guidance on how to get this accomplished? I've only been able to read the csv and get the data with fopen. I'm not sure how to change create the date format I need from the file.



Tony (view profile)

on 28 Mar 2013

I got it to work with CSVREAD, I'm trying to create a new csv with the following method. Except instead of showing a 0 in the last like the code is trying to do, its showing 48... I have no idea where that is coming from

 dataLine = csvread(([archiveDir list1(j).name]));
    fid = fopen('temp.csv', 'w');
    fprintf(fid,'%s,%6.8f,%6.8f,%6.8f,%6.8f,%d\n', datestr(x2mdate(dataLine(2)),''),dataLine(6),dataLine(6),dataLine(6),dataLine(6),'0');

Tony (view profile)

on 28 Mar 2013

This is the output:


per isakson

per isakson (view profile)

on 28 Mar 2013


    >> double('0')
    ans =

Tony (view profile)


No products are associated with this question.

0 Answers

Contact us