Import data with double and strings
古いコメントを表示
Hello everybody,
I have a file (*.txt as attached). This file contains data perfilated with an equipment, displayed in a first column of date/time and four columns of numeric values (depth and water quality). Each profile is preceeded by a 6 lines heading (text data) and a given file may contain many profiles (always preceeded by a 6 lines heading).
Example:
Sensor Data Columns
Sensor Statistics (sensor #, Description, Statistic)
1 Depth Mean
2 OBS-1 (NTU) Mean
4 Temperature (deg C) Mean
5 Conductivity (mS/cm) Mean
16:15:35.0 07/15/2019 9.92 2422.9 28.77 6.73
16:15:35.5 07/15/2019 9.92 2422.9 28.77 6.73
16:15:36.0 07/15/2019 9.95 2422.9 28.77 6.72
16:15:36.5 07/15/2019 9.98 2422.9 28.77 6.73
16:15:37.0 07/15/2019 10.01 2422.9 28.77 6.72
16:15:37.5 07/15/2019 10.03 2422.9 28.77 6.74
16:15:38.0 07/15/2019 10.02 2422.9 28.77 6.74
The problem is that there are 5 spaces separating date/time and the column showing the depths, but only four spaces for depths greater than 9.9m. When I use:
OBS = importdata(AM2_15_1a.txt,' ',6);
It creates a strcut separating text and numeric data, which is exactly what I want, except that for depths > 9.9m, the lines are read as 0.1 (instead of 10.1) and the remaining "1" is put together with the date column which bugs the analysis.
As I have many files with many lines, is there any solution for fixing this problem? I tried pasting data to excel and then back to the log file; changing to csv and other types in order to standardise the columns separators, but when I do that, "importdata" doesn't work (it doesn't create a struct, but a cell containing only the heading.
Any sugestion? Thanks in advance
Best regards!
2 件のコメント
Bob Thompson
2019 年 9 月 24 日
編集済み: Bob Thompson
2019 年 9 月 24 日
Diego Fonseca
2019 年 9 月 24 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!