1.

Solve : i want to give command in DOS regard to do reading a dat file and copy line 9 c?

Answer»

please help me...not sure how a .dat file is set up, but try this:


Code: [SELECT]for /f "tokens=9 delims=" %%G in (FILENAME.dat) do set line9=%%G

echo %line9%
pause
sample of .dat file is like this :

diana_w6436 Page 1

ANALYSIS type FLOW
Time 3.000E+02
Step nr. 1
Result TEMPER TOTAL

Nodnr PTE
1575 [ 1.551E+01 ] <<<<<---------------- this values []


Analysis type FLOW
Time 6.000E+02
Step nr. 2
Result TEMPER TOTAL

Nodnr PTE
1575 1.413E+01 <<<<<---------------- this values []



now, for me it is important to select the values from .dat file (for instance the first one placed at line 9 and started from CHARACTER 10 to 14)
and copy this values to excel sheet by using DOS command .

please inform me if you need more information
regards



Lemonilla, I think you mean skip=8, not tokens=9, and also if there are more than 9 lines in the file, %line9% will contain the last line, not the 9th. So you need to jump out of the loop to a label as soon as one line is read - the 9th, because we skipped the first 8 lines.

You should test code first and not post guesswork code that came off the top of your head.

Code: [Select]for /f "skip=8 delims=" %%G in (test.txt) do set line9=%%G & goto jump
:jump
echo %line9%
Code modified to give 2nd space delimited token on line 9

Code: [Select]@echo off
for /f "skip=8 tokens=1,2 delims= " %%G in (test.dat) do set value9=%%H & goto jump
:jump
echo %value%
That'll teach me to lecture people... my code has a typo, here is the corrected version:

Code: [Select]@echo off
for /f "skip=8 tokens=1,2 delims= " %%G in (test.dat) do set value=%%H & goto jump
:jump
echo %value%



This seems to be what the OP REQUIRES:

It creates file.csv from file.dat and includes all the lines you require, according to the sample you provided.

Code: [Select]@echo off
for /f "tokens=2" %%a in ('find "+"^< "file.dat"^|find /v /i "time"') do (
set /p "=%%a,"<nul >>file.csv
)



Discussion

No Comment Found