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
1 answer

Scrape text file with Python and save to new text file as values

I have multiple files with different names in a directory with content like this: Combination :3 Tuple Number:3 Request Type:ADD Firewall Type:JP Firewall Policy Name :STI-CEP31 Rule Type: ALLOW Requested Values: Policy Name Suffix: Source…
Noah
  • 35
  • 4
1
vote
1 answer

using textscan to read badly formatted CSV file in Octave

I am trying to read a CSV file in Octave with textscan and the CSV file isn't always correctly formatted. The following mcve should illustrate the issue: Let's say the file is as…
am304
  • 13,758
  • 2
  • 22
  • 40
1
vote
1 answer

How to convert a string to a table with `textscan`?

I'm using matlab to read in COVID-19 data provided by Johns Hopkins as a .csv-file using urlread, but I'm not sure how to use textscan in the next step in order to convert the string into a table. The first two columns of the .csv-file are strings…
Christian
  • 33
  • 2
1
vote
1 answer

Read Large Text File with a While Loop into MATLAB

I am trying to read a large 3 GB text file into MATLAB, organized by a header with names, and with a delimiter of a space (see below fruit.txt) However, the only data needed is the Grapes Column. Since it is a huge file, I am using a loop below to…
Minimalist
  • 963
  • 12
  • 34
1
vote
1 answer

read csv file in matlab with rows of different size

I'm going to read a big csv file in matlab which contains rows like this: 1, 0, 1, 0, 1 1, 0, 1, 0, 1, 0, 1, 0, 1 1, 0, 1 1, 0, 1 1, 0, 1, 0, 1 0, 1, 0, 1, 0, 1, 0, 1, 0 For reading big files I'm using textscan however I should define number of…
VSB
  • 9,825
  • 16
  • 72
  • 145
1
vote
2 answers

How can i read text file and load data to an array?

I have a .txt file that follows the next format: 00:00.300 ID:4 zzzzzzzzzzz 00:02.155 ID:4 aaaaaaaaaaaaa 00:04.662 ID:4 dsadasd **00:32.283** ID:4 level **790** 00:32.155 …
1
vote
1 answer

reading tabstops as 4 whitespaces using textscan

Is it possible to tell MATLAB's textscan to import tabs as four whitespaces? Currently it's replacing a tab with just one whitespace: raw = textscan(fid,'%s','Delimiter','\n','Whitespace',''); Thank you in advance :)
Johannes
  • 135
  • 5
1
vote
1 answer

Why can't the matlab textscan function read + 22.24 as a float?

I'm currently having a problem with the matlab function textscan. I got a data file which looks like this: 1,2018/08/14 17:06:15, 0,+ 22.24,+ 22.46,+ 18.18,+0.0000,+0.0005,LLLLLLLLLL,LLLLLLLLLL,LLLL or sometimes when a sensor isn't working…
Momo
  • 11
  • 1
1
vote
2 answers

What is the c++ translation for 'textscan' function from Matlab?

What is a simple translation in code for 'textscan' from matlab into C or C++? I am using Ubuntu and I am trying to translate a Matlab code into C++. Thank you very much.
js0823
  • 1,843
  • 8
  • 24
  • 36
1
vote
1 answer

How can I obtain only word without All Punctuation Marks when I read text file?

The text file abc.txt is an arbitrary article that has been scraped from the web. For example, it is as follows: His name is "Donald" and he likes burger. On December 11, he married. I want to extract only words in lower case and numbers except…
Danny_Kim
  • 299
  • 2
  • 18
1
vote
1 answer

How do I read the rest of a line of a text file in MATLAB with TEXTSCAN?

I am trying to read a text file with data according to a specific format. I am using and textscan together with a string containing the format to read the whole data set in one code line. I've found how to read the whole line with fgetl, but I would…
Smartskaft2
  • 468
  • 3
  • 16
1
vote
1 answer

Blank cells while reading substring and numbers from with a string with textscan

I have a text file that consists of line after line of data in an xml-like format like this:
jpmorr
  • 500
  • 5
  • 25
1
vote
1 answer

Matlab: how to read correctly the months from a .txt file

I tried to read to .txt files in Matlab that include monthly information about solar radiation and temperatures. The months are as text i.e Jan, Feb, etc. Then with this information need to make some graphs to display the information per month, like…
1
vote
1 answer

Read lines with unformatted number of elements in matlab

I would like to read files containing numbers in each line. Here is the example of the file format- boundary-points-x: 0.00 5.00 boundary-points-y: 0.00 0.10 0.20 0.30 4.90 boundary-points-z: 0.00 1.00 2.00 3.00 4.00 5.00 The number after literal…
dinex
  • 367
  • 5
  • 15
1
vote
1 answer

Matlab (textscan), read characters from specified column and row

I have a number of text files with data, and want to read a specific part of each file (time information), which is always located at the end of the first row of each file. Here's an example: %termo2, 30-Jan-2016 12:27:20 I.e. I would like to get…
Neuroguy
  • 131
  • 1
  • 1
  • 9