How do I ignore delimiter inside quotation marks using regexp?
4 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone,
I'm writing a script to import data. The size (coloumns) of the data can vary. The main delimiter is a semicolon.
My data looks like the following:
Header ; Value ; Data
Example1; 12 ; "air"
Example2; 24 ; "water"
For this usecase I'm using
filebyfield = regexp(filebyline, ';', 'split'); %filebyline- textfile including my data
Unfortunately the data I try to import isn't uniform and could look like the following:
Header ; Value ; Data
Example1; 12 ; "air;fire"
Example2; 24 ; "water"
Is there any way to ignore the delimiter (";") if its inside of quotation marks? I thought about textscan, but I don't have the same number of coloumns every time and therefore cant specify the data format.
Any help would be appreciated! Best regards
0 件のコメント
採用された回答
Walter Roberson
2020 年 11 月 4 日
sometimes the easiest way is to detect the quoted delimiter and replace them with some special character such as ¡ and then do the split and then fix-up the results.
4 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!