MATLAB Answers

Convert homogenous string array into a table or excel file separated into data

1 view (last 30 days)
Esteban Schrick
Esteban Schrick on 17 Jun 2021
Answered: Prateek Rai on 17 Aug 2021
My job is to turn a textfile into a table or excel sheet. I have already created an array with the textfile lines that contain the information i need. Here is an example of what each index contains:
{'08/06/21_23:38:50.166→Defect_found: CHANNEL_18; ID; Pos. = 2420 [mm]; 239.9 [deg]; Ampl = 2.84 [V]; Freq = 200 [Hz]; Length = 60.0 [mm]; Insp_num = 2775798' }
This is all one string but i need to seperate each piece of information and turn it into a table or preferable an excel sheet.
If you need any more information please let me know. Thank you so much!

Answers (1)

Prateek Rai
Prateek Rai on 17 Aug 2021
To my understanding, you are trying to turn a text file into a table or excel sheet. You can go with the following workaround:
  • Step 1: Use 'readtable ' to read .txt files into a table.
T = readtable(input_filename)
  • Step 2: Use 'writetable' to write it to excel file.
writetable(T,outout_filename) % Extension must be specified by output_filename.
You can refer to readtable MathWorks documentation page to find more on creating table from file. You can also refer to writetable MathWorks documentation page to learn more on writing table to file.

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!