Kulis
Kulis

Reputation: 1010

Converting columns to strings

I have many files, with different numbers of columns (.txt files). How to automaticaly change this %s%s%s... string to correspond numbers '%s' to amount of column?

data=textscan(fid,'%*s%*s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%','HeaderLines',skip_lines,'CollectOutput',1); 

The files looks like:

file

I have algoritm which load many files and it will nice, when I could automatize this.

Upvotes: 1

Views: 57

Answers (1)

User1551892
User1551892

Reputation: 3364

try this method:

importdata('path to file')

You can specify the delimiter as well. this method is adaptive and you do not need to take care about columns. This method return the header, text data and number data in separate variables.

Upvotes: 1

Related Questions