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
0
votes
2 answers

How to read multiple files into a single cell array?

I have a large dataset split into 5 files (each has 15000 attributes, first file contains header (attribute names) and 9999 records, and the other 4 contain 10000 records). Using textscan, I have created 5 cell arrays which have to be merged and…
Niko Gamulin
  • 66,025
  • 95
  • 221
  • 286
0
votes
1 answer

Importing textscan

I have a large CSV data and I tried to import using textscan. The data has some letters NA in the inside the data. I used the following script, however out of 215842 rows only 11 are recognized. The data importing stopped at row where it encouter…
0
votes
1 answer

Matlab to read in fix-width text file

I have a text file like below: TestData 6.84 11.31 17.51 22.62 26.91 31.98 36.47 35.85 28.47 20.57 10.50 6.37 test1 0.24 2.62 4.94 7.17 10.39 15.37 18.73 18.29 12.26 …
James
  • 99
  • 9
0
votes
1 answer

Matlab - read specifics of textfile and give specific output

I have a text file in Matlab that contains comment strings as well as variables and I am trying to figure out the best way to read this file and give an output as different variables that can easily be plugged into equations later on. The text file…
0
votes
1 answer

Matlab textscan formatspec delimiter error

When reading a large csv file Matlab doesn't recognize ||,|| as a proper delimiter as input argument for textscan. The data is as follows (simplified): ||X||,||Y||,||Z|| (header) ||1||,||2||,||4|| ||4||,||4||,||3|| etc. I use data =…
Max
  • 1
0
votes
1 answer

Calling specific numbers from an non formatted text file in matlab

I have a text file which consists: // MATLAB to process this file ModelName : Matlab1 PerturbationId : 0 X1X2_001 : 0.270971584968118 X1X2_002 : 0.55555 OBJECTF : ? NumberOfRuns : 25 SimulationId : 0 What I want to do is to get 0.270971584968118…
masoud
  • 1
0
votes
1 answer

Matlab textscan introducing additional rows with zeros or NaNs

I'm trying to read a .dat file containing tens of thousands of rows, where each of them looks something like: 1.9681968 0 0 19.996 0 61 100 1.94E-07 6.62E-07 2.330233 0 0 19.996 0 61 100 1.94E-07 6.62E-07 …
woodenflute
  • 325
  • 2
  • 7
0
votes
1 answer

Read ASC file into MATLAB using textscan - variable column lengths

I am trying to read the following data into MATLAB: '0.000000 1 18EFFA59x Rx D 8 AD 09 02 00 00 00 00 30' '0.004245 1 14EFF01Cx Rx D 6 DB 00 FF FF 00 71' '0.004640 1 CEF801Cx Rx D 3 3F 00 3B' '0.005130 1 14EF131Cx Rx…
0
votes
2 answers

MATLAB: textscan using width delimited txt file

I'm trying to import a width delimited txt file using the textscan function. The file is 80 characters wide, with no delimiter, and the desired resulting 12 columns are different widths of characters. I have tried to do this by specifying the width…
CeeGee
  • 13
  • 2
0
votes
1 answer

Matlab - read textfile and extract data from specific row

I have a text file which is an output from the command line of a diff program. I now read the file using fileID = fopen('runInfo.out','r'); file_dump = textscan(fileID, '%s', 'Delimiter', '\n'); % Find postion of Min Cp to mark field on…
Ash
  • 318
  • 3
  • 14
0
votes
1 answer

Breaking MATLAB Text Scan Output into a table

I'm working on some MATLAB code that parses a .csv file into a table. The CVS file has seven columns separated by commas and also contains thousands of rows. Right now the parsing code looks like this: fid = fopen('data.csv', 'r'); parsed =…
James Taylor
  • 6,158
  • 8
  • 48
  • 74
0
votes
3 answers

How to read text file with variable row length in Matlab?

I have of bunch of CSV files to read in Matlab. All of files has similar structure, except last field is optional. I.e. some files contain it, others are not. Also files contain both textual and numeric fields, so csvread is not applicable. Only…
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
0
votes
2 answers

Reading data using textscan in MATLAB

I need to read the following data from a text file in MATLAB. This is just a sample, the actual matrix contains data from 1218 stations (USH denotes for US and the number adjacent to that is station ID), each column being the monthly value. Column…
user962808
  • 115
  • 1
  • 2
  • 10
0
votes
1 answer

Reading text file in Matlab results in unknown spaces within characters

I am trying to read a text/csv file in Matlab.The file looks…
Amitava
  • 431
  • 2
  • 6
  • 21
0
votes
3 answers

Textscan Matlab ; Doesn't read the format

I have a file in the following format: **400**,**100**::400,descendsFrom,**76**::0 **400**,**119**::400,descendsFrom,**35**::0 **400**,**4**::400,descendsFrom,**45**::0 ... ... Now I need to read, the part only in the bold. I've written the…
Prateek
  • 41
  • 1
  • 5