Questions tagged [textscan]

Matlab function for reading formatted data.

textscan is a Matlab function for reading formatted data from text file or string.

For more details, see the Matlab's official doc.

222 questions
1
vote
2 answers

Error reading a fixed-width string with textscan in MATLAB

I'm reading fixed-width (9 characters) data from a text file using textscan. Textscan fails at a certain line containing the string: ' 9574865.0E+10 ' I would like to read two numbers from this: 957486 5.0E+10 The problem can be replicated like…
user1719360
  • 193
  • 6
1
vote
1 answer

Convert DAT file to a CSV format using Matlab

I have the following text file, THERM2.DAT which has a unique format: Ag+ g10/97AG 1.E -1. 0. 0.G 298.150 6000.000 1000. 1 9.72687035E+00-4.01472180E-03 7.47796464E-07-1.76595533E-11-4.14279861E-15 2 …
wigging
  • 8,492
  • 12
  • 75
  • 117
1
vote
1 answer

textscan in Matlab when delimiter is in a field and what to ignore " character

Using textscan I'm trying to read a file that has comma separated data in the following format: "1234","24.0","Hello, my name is Joe" "4567","25,0","Hi, I'm Jane" The non-delimiter comma in the third field are problematic and I ultimately don't…
user1507844
  • 5,973
  • 10
  • 38
  • 55
1
vote
1 answer

How do I consume multiple outputs of `textscan` function in a single line?

Suppose I have the following string: s = 'Foo 1.000 3.000 3.554' I would like to read it with the textscan function as follows. [name x y z] = textscan(s, '%s %f %f %f') However, when I do this, I always get the Too many output arguments error.…
merlin2011
  • 71,677
  • 44
  • 195
  • 329
1
vote
3 answers

Skip multiple points of 'x' and store and variable 'newdata in matlab

I have data stored in variable data. data = [43.98272955 39.55809471; -49.51656799 28.57164726; -9.475861028 -44.31264255; 27.14884251 2.603921223; -2.914496888 7.864022006; 4.093025860 …
1
vote
2 answers

Reading text file using fscanf in octave / matlab into cell array

I have a comma delimited single text file with strings and integers that I'm trying to import into a cell array. I then want to export it to several files based on the same Resonance Freq. and add text to the filename row This is a sample of the…
Rick T
  • 3,349
  • 10
  • 54
  • 119
1
vote
2 answers

Scanning data from cell array and removing based on file extensions

I have a cell array that is a list of file names. I transposed them because I find that easier to work with. Now I am attempting to go through each line in each cell and remove the lines based on their file extension. Eventually, I want to use this…
1
vote
2 answers

how can I import multiple csv files with selected columns using textscan?

I have a large number of csv files to be processed. I only want the selected columns in each file and then load all the files from a certain folder and then output as one combined file. Here are my codes running with errors.... Could anyone help me…
Jackie
  • 73
  • 1
  • 10
1
vote
1 answer

text scan iterations

I have some files to process , but i have missing files in middle i am using for i=1:file; fid = fopen(['Raw',num2str(i),'.txt']); D = textscan(fid1,'%*f %f%*f%*f%*f%f%f%[^\n]','delimiter',';', 'headerlines',50,'CollectOutput',…
AP.
  • 750
  • 3
  • 12
  • 19
1
vote
2 answers

MATLAB: Convert comma separated single cell to multiple cell array whilst maintaining UTF-8 encoding using textscan

From the beginning. I have data in a csv file like: La Loi des rues,/m/0gw3lmk,/m/0gw1pvm L'Étudiante,/m/0j9vjq5,/m/0h6hft_ The Kid From Borneo,/m/04lrdnn,/m/04lrdnt,/m/04lrdn5,/m/04lrdnh,/m/04lrdnb etc. This is in UTF-8 format. I import this file…
Griff
  • 2,064
  • 5
  • 31
  • 47
0
votes
2 answers

Trying to read a text file...but not getting all the contents

I am trying to read the file with the following format which repeats itself (but I have cut out the data even for the first repetition because of it being too long): 1.00 'day' 2011-01-02 'Total Velocity Magnitude RC - Matrix' 'm/day' 0.190189 …
user238469
0
votes
1 answer

Finding the lines where specific strings reside when reading a text file from Matlab

I have a text file that has consequtive integer values around strings. This file looks like that: This is the set for x = 100 --------------------------- For y=COLUMN 1 we have 1232 3ff3 4a45 23d4 5323 ... ... END of COLUMN 1 meas For y=COLUMN 2…
limp
  • 889
  • 2
  • 14
  • 22
0
votes
1 answer

Storing data to seperate arrays after specific strings appear in text file

I would like to have an m-file that will be able read a text file and store each set of data into separate arrays. A set of data is a range of hex values appeared between specific strings. The format of the text file is similar to the…
limp
  • 889
  • 2
  • 14
  • 22
0
votes
0 answers

Matlab Scan csv file for data and then read

I have a similar question to MATLAB CSV File Read, but slightly more complicated. In my instance, as well as having header lines that the start of my data, the data is separated into steps all in the same file like below: headers 1,2,3 more…
user2587726
  • 169
  • 2
  • 11
0
votes
1 answer

MatLab textscan(), from messy format with missing lines

I'm not familiar with MatLab textscan(). Any help you could provide would be much appreciated. The text file that I want to read looks as follows: test.0.xml myFunc(x) = 0.0294118 execution time: 5.87ms test.1.xml myFunc(x) = 0.0625 execution time:…
Anouk
  • 1
  • 1