help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Importing a xls (?) formatted csv file


From: Jobaat
Subject: Importing a xls (?) formatted csv file
Date: Wed, 29 Apr 2015 11:28:50 -0700 (PDT)

Hi,

I just new to Octave (but have some basic understanding of Matlab) and I'm
trying to read a csv file into Octave (primarily the data into a matrix).
The file itself is not delimited by comma and seems to follow Excel format
(double click to open in Excel works). I have tried textscan, dlmread,
xlsread with various not that successful results. I have used \t and \n as
delimiters and also tried to set offset to skip the header. The data has
comma as decimal mark and I have tried to replace the commas with dot. The
last attempt was to use xlsread to convert the file into ascii format using
the code below. However, the data is not recognized and I get the following
message: "Detected XLS interfaces: None.
warning: xlsopen.m: no support for '.xls' spreadsheet I/O"

If I open the file in Excel or word it looks like the below. However, if I
open it in notepad it does not recognize the \n. 

*Latest attemt:*

[FileName,PathName] = uigetfile('*.csv','Select file')
FileExt='.oct';
NewFileName=strcat(FileName,FileExt);
copyfile(FileName,NewFileName); %I want to keep the original file

Data = fileread(NewFileName);
Data = strrep(Data, ',', '.');
FID = fopen(NewFileName, 'w');
fwrite(FID, Data, 'char');
fclose(FID);

[numData textData rawData] = xlsread(NewFileName),
save('pqfile.txt', 'rawData', '-ascii');

*csv file copied from wordpad below. Link to the csv file:*
https://www.dropbox.com/s/5nuitho1g7x4jp1/Testfile1.csv?dl=0

Name:   Data 0x2007 0x0957 4/9/2015 10:52:38
Owner:  utvuser
Comments:       
Acquisition Date:       9.4.2015 10:52:38
&Instrument:    34972A  Address:        USB0::0x0957::0x2007::MY49017264::INSTR
Modules:        2       Slot1:  34901A  Slot2:  34901A
Total Channels: 2
Channel Name    Function        Range   Resolution      AdvSettings     Scale   
Gain    Offset  Label
Test    Low     High    HWAlarm
202             DC Voltage      Auto    5,5     DC 
Voltage#10M#1#0,016#Auto#0,001       False   1       0       VDC     Off
0       1       Alarm 1
211             DC Voltage      Auto    5,5     DC 
Voltage#10M#1#0,016#Auto#0,001       False   1       0       VDC     Off
0       1       Alarm 1
Scan  Control:  Start Action:   Immediately     Stop Action:    User Terminated
Time    Elapsed 202 (VDC)       211 (VDC)
9.4.2015 10:52:38       00:00:00:00     1,895661        4,843478
9.4.2015 10:52:41       00:00:00:03     1,8867291       4,8384305
9.4.2015 10:52:44       00:00:00:05     1,8807212       4,8351544
9.4.2015 10:52:47       00:00:00:09     1,8741371       4,8309606
9.4.2015 10:52:50       00:00:00:12     1,9097897       4,8522177
9.4.2015 10:52:53       00:00:00:14     1,9536165       4,8766015
9.4.2015 10:52:56       00:00:00:18     1,9683214       4,8846156
9.4.2015 10:52:59       00:00:00:21     2,0051054       4,9034823
9.4.2015 10:53:02       00:00:00:23     2,0179643       4,9099491
9.4.2015 10:53:05       00:00:00:27     2,0760584       4,9378866

Any suggestions would be highly appreciated.

Thanks,
Johan



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Importing-a-xls-formatted-csv-file-tp4670150.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]