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
11
votes
4 answers

Python equivalent of Matlab textscan

I'm working with transferring some Matlab code to Python. I'm relatively new to Python and am unsure of a Python equivalent of Matlab's textscan method. Any help would be greatly appreciated.
shadonar
  • 1,114
  • 3
  • 16
  • 40
9
votes
4 answers

Avoid typing conversion specifier for every column in large table in `textscan`

I am reading data from a table using textscan(). The table has 90 columns and I want to read each column's values as a floating-point number. Looking at the documentation, I have to use specifier %f - but it seems I need to use it 90 times, so I end…
Geek On Acid
  • 6,330
  • 4
  • 44
  • 64
6
votes
2 answers

Ignore " character when using textscan() in MATLAB

I am using textscan to read data from a file. The data being read is: "ABC",0.156 "DEF",0.125 "GHI",0.101 My code is - data = textscan(fid, '%s %f', 'Delimiter', ','); data{1} come as '"ABC"' '"DEF"' '"GHI"' I want the data{1} as…
Maddy
  • 2,520
  • 14
  • 44
  • 64
6
votes
2 answers

textscan in Matlab uses excessive RAM compared to similar method in R

I run Matlab R2011b and R version 2.13.1 on Linux Mint v12 with 16 GB of RAM. I have a csv file. The first 5 rows (and header) is: #RIC,Date[G],Time[G],GMT…
Colin T Bowers
  • 18,106
  • 8
  • 61
  • 89
5
votes
1 answer

Textscan on file with large number of lines

I'm trying to analyze a very large file using textscan in MATLAB. The file in question is about 12 GB in size and contains about 250 million lines with seven (floating) numbers in each (delimited by a whitespace); because this obviously would not…
Julius
  • 304
  • 4
  • 16
5
votes
2 answers

Splitting a timestamp in Matlab

I have a file with a data value and timestamp that I am trying to split in Matlab. This is the format: -18.151346 Mon Jan 28 11:33:08 2013 I am using the textscan function to try and split…
Bob
  • 53
  • 3
4
votes
2 answers

Read CSV with semicolon separated data with comma as decimal mark in matlab

My problem is, that I've got CSV-data of the following format: 1,000333e+003;6,620171e+001 1,001297e+003;6,519699e+001 1,002261e+003;6,444984e+001 I want to read the data into matlab, but csvread requires it to be comma separated, and I have not…
Niels Møller
  • 203
  • 1
  • 3
  • 9
4
votes
1 answer

How to textscan with multiple delimiters

I am trying to read in a file with contains thousands of lines of the format: AAAAAAAA 2013.99.2314.029 0 OFF N Which is a tab delimited file. The last column is a don't care. The two columns before that are variable, so I read them as…
polkid
  • 313
  • 4
  • 15
4
votes
2 answers

MATLAB: Using textscan and converting cell array in matrix

I have a large csv file (should be around 1 million lines) with option data with the following structure (content is altered): secid, date, days, delta, impl_volatility, impl_strike, impl_premium, dispersion, cp_flag, ticker, index_flag,…
sasstudent
  • 187
  • 1
  • 2
  • 11
4
votes
1 answer

Importing large textfile to matlab (including comments; textscan)

Im trying to import big txt files (>1gb) to matlab. this is the data structure: 667.55535 -0.00 0.000 0.0158 667.5554 -0.01 -0.000 0.0158 667.55545 -0.01 4.037 10.0000 667.5555 -0.00 4.000 10.0000 #1 Trigger Camera 10 Hz #2…
3
votes
2 answers

importing a CSV file in MATLAB

How can I import a CSV file into MATLAB?. A row in the file i am working with looks like: SUNW,2-Jan-98,1998,5,40.125,41.5 There are 36 columns and 10107 rows. The first row contains the column headers. It seems that MATLAB doesn't support…
AbbyJ
  • 75
  • 3
  • 9
3
votes
1 answer

Nested textscan statements

The following two statements read the first line from an input file (fid) and parse said line into strings delimited by whitespace. a = textscan(fid,'%s',1,'Delimiter','\n'); b = textscan(a{1}{1},'%s'); I would like to know if this action can be…
user001
  • 1,850
  • 4
  • 27
  • 42
3
votes
2 answers

MATLAB / Octave - how to parse CSV file with numbers and strings that contain commas

I have a CSV file that has 20 columns. Some of the columns have number values, others have text values, and the text ones may or may not contain commas. CSV content example: column1, column2, column3, column4 "text value 1", 123, "text, with a…
jotadepicas
  • 2,389
  • 2
  • 26
  • 48
3
votes
1 answer

Reading a file with a few empty values using textscan

I'm trying to read a textfile using textscan but I'm having some issues. I found out textscan doesn't read empty values, but I can't get it to work. I've tried using this, and I even replaced \t with 'space' but it's just returning blank arrays and…
Paulo Maia
  • 63
  • 4
3
votes
2 answers

Conditional text import or import by header name - MATLAB

Is there a way to perform conditional text import within MATLAB? e.g. with a tab-delimited .txt file in this format: Type A B C D E A 5000 2 5 16 19 A 5000 3 4 5 4 A 5000 4 1 4 5 B 500 19 8 2 7 …
AnnaSchumann
  • 1,261
  • 10
  • 22
1
2 3
14 15