Copy dedicated values from a text file and store them inside Excel sheet

1 view (last 30 days)
hello. I have several text files which have data stored in them in following manner:
1.1 ECU Identification (Ford Escape Initial)
PDU Parameter Value Unit
[7E8]
06 00 OBDMIDs OBDmonitorIDsSupported$01_$1F
ExhaustGasSensorMonitorBank1Sensor1 supported
ExhaustGasSensorMonitorBank1Sensor2 supported
06 01 Monitor ID ExhaustGasSensorMonitorBank1Sensor1
testValue 0.009 s
minimumTestLimit 0.000 s
maximumTestLimit 0.400 s
Test ID 0x87
Monitor ID ExhaustGasSensorMonitorBank1Sensor1
testValue 0.020 s
minimumTestLimit 0.000 s
maximumTestLimit 0.400 s
Test ID 0x88
06 02 Monitor ID ExhaustGasSensorMonitorBank1Sensor2
testValue -7876 mV/s
minimumTestLimit -30000 mV/s
maximumTestLimit 0 mV/s
Test ID 0x85
Monitor ID ExhaustGasSensorMonitorBank1Sensor2
testValue 1.889 s
minimumTestLimit 0.000 s
maximumTestLimit 6.000 s
Test ID 0x86
06 20 OBDMIDs OBDmonitorIDsSupported$21_$3F
CatalystMonitorBank1 supported
VVTMonitorBank1 supported
EVAPmonitorCapOff not supported
EVAPmonitor_0_090 supported
EVAPmonitor_0_040 supported
EVAPmonitor_0_020 supported
PurgeFlowMonitor supported
and so on...
I need to copy and store the values given in the parameter and value columns against PDU values in an Excel sheet. I am fairly new to MATLAB programming and I know xlsread can be used in this Situation but I dont know how. Any Kind of help in this regard is greatly appreciated. Thank you.
  8 Comments
yousaf obaid
yousaf obaid on 2 Jun 2016
Edited: yousaf obaid on 2 Jun 2016
actually no. 0X87 should remain 0X87. And the above format that you posted seems about right, except that it should be 06 00 instead of '06' '00' and so on.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 3 Jun 2016
Are you sure you want the 06 00 to come out as numeric? Those are hex values not decimal. Did you possibly mean that you wanted '06 00' instead of '06' '00'?
I have attached a function to read the contents of one of these files. The code converts the hex PDU numbers to decimal because you seemed to request that. You also implicitly approved that for example '0.009' should become 0.009 so I convert the 4th column to numeric whenever that works out and leave it as text when it does not.
The output of the code is a cell array that you can then xlswrite().
Example:
odx = readodx('Test1.txt');
xlswrite('Test1.xlsx', odx);
For consistency, I convert all empty fields to the empty numeric array, [], rather than to empty strings, ''
Empty lines are skipped.
The column numbers and widths are hard-coded, the P and L vectors in the code. The string fields are permitted to contain blanks, which would make it difficult for the program to figure out where the columns started.
The starting line is not hard-coded, but the code currently does expect to see the 'PDU' line and for there to be the dashed line below it.
  1 Comment
yousaf obaid
yousaf obaid on 6 Jun 2016
Thank you so much for the detailed answer. With some tweaks here and there, i managed to run it successfully. Thank you once again.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!