import from text file then export variables

November 29, 2011 at 09:55:11
Specs: Win 7 Ultimate , 4.17Ghz 8GB ram
I'm wondering how to take the output of a text file will be in column format and have varying number of inputs. Then I need to have these output into another file in a row format

See More: import from text file then export variables

Report •


#1
November 29, 2011 at 14:10:45
An example of what the input file looks like and how you want it reformatted would help.


Please come back & tell us if your problem is resolved.


Report •

#2
November 29, 2011 at 15:17:21
Input:

SX 2.500000e+00
SY -2000000e+00
SC 9.000000e+01
OB 5.500000e-03

Where e is the exponent I need the first 4 digits of each number


Then the output would be:
SX%that number above with only first 4 digits%SY%VAR%SC%VAR%OB%VAR%

I believe there is a way to do it with a token by getting the number and the variable it is associated with but I don't know how to factor in the exponents


NOTE: the variable SC,SX etc will always be the same


Report •

#3
November 29, 2011 at 17:50:59
Please test this:

@echo off
cls
setlocal enabledelayedexpansion

for /f "tokens=1*" %%1 in (input.txt) do (
    set value=%%2
    set out=!out!%%1!value:~0,-7!
)
echo %out%>output.txt


Please come back & tell us if your problem is resolved.


Report •

Related Solutions

#4
November 30, 2011 at 18:12:01
That kind of worked. There is more to the text file that what i just sent you. I was thinking there was a way to pick out that specific line?

Here is a sample of the text file (input)

Local Parameters
----------------

Symbolic constant Current value Properties
------------------------------- -------------------- ---------------------------
SX 2.500000e+00 TYPE: Real Number
SOURCE: Relation
ACCESS: Locked
DESIGNATED: NO
DESCRIPTION:

SY -2.000000e+00 TYPE: Real Number
SOURCE: Relation
ACCESS: Locked
DESIGNATED: NO
DESCRIPTION:

SZ 4.000000e+00 TYPE: Real Number
SOURCE: Relation
ACCESS: Locked
DESIGNATED: NO
DESCRIPTION:

SC 9.000000e+01 TYPE: Real Number
SOURCE: Relation
ACCESS: Locked
DESIGNATED: NO
DESCRIPTION:

X 2.500000e+00 TYPE: Real Number
SOURCE: Relation
ACCESS: Locked
DESIGNATED: NO
DESCRIPTION:

Y -2.000000e+00 TYPE: Real Number
SOURCE: Relation
ACCESS: Locked
DESIGNATED: NO
DESCRIPTION:


NOTE:Also there are multiple spaces in between the sx and the number (this forum will not let me add them)


Report •

Ask Question