SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
JTB
Topic Author
Posts: 221
Joined: August 20th, 2010, 9:28 am

MATLAB : Reading txt-file with delimiter problem

September 7th, 2013, 3:22 pm

I have a file with the following structure:"Hans", "Hanson", "2","5.9000,14""Kim", "Jung", "3","5.9000,16"Trying dataset('File',folderIndex(i,1).name,'Delimiter',',') gives one extra column due to 5.9000,14-value is splitted into two extra columns. Any smooth fix for this problem?
 
User avatar
Cuchulainn
Posts: 63251
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

MATLAB : Reading txt-file with delimiter problem

September 7th, 2013, 5:55 pm

edit: (sorry, wrong post)
Last edited by Cuchulainn on September 6th, 2013, 10:00 pm, edited 1 time in total.
Chips chips chips Du du du du du Ci bum ci bum bum Du du du du du Ci bum ci bum bum Du du du du du
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
tagoma
Posts: 18382
Joined: February 21st, 2010, 12:58 pm

MATLAB : Reading txt-file with delimiter problem

September 7th, 2013, 6:56 pm

(i've never used Matlab)i would try to cheat Matlab as follows:- open your file in notepad, CTRL+H replace [$]",[$] with a [$]"+[blank space],[$] - set your delimiter as blank space (probably something like [$]""[$] with Matlab)
 
User avatar
OOglesby
Posts: 42
Joined: August 26th, 2011, 5:34 am

MATLAB : Reading txt-file with delimiter problem

September 7th, 2013, 8:17 pm

JTB,Try the following code snipped and see if it can read your file. Textscan is a much more complicated function to use, but incredibly flexible. The text data will be stored in a cell array. There is plenty of documentation about cell arrays if you are not familiar with them.As a caveat, I have not tried this code to ensure no typos or bugs, but it should be a starting point.
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On