hello

J want to inverse the line of a fichier
do you know, how do this please
thank you

Re: inverse line fichier by Pegasus

Pegasus
Sat Oct 20 14:12:39 PDT 2007


"Alain Terieur" <alain@terieur.fr> wrote in message
news:471a4ac2$0$25924$ba4acef3@news.orange.fr...
> hello
>
> J want to inverse the line of a fichier
> do you know, how do this please
> thank you
>

It depends on what you mean. If the source file
looks like so:
ABC
DEF
GHI
do you want this:
CBA
FED
IHG
or this:
GHI
DEF
ABC



Re: inverse line fichier by Alain

Alain
Sun Oct 21 00:19:54 PDT 2007

hello

I want this
GHI
DEF
ABC

thank

"Pegasus (MVP)" <I.can@fly.com> a écrit dans le message de news:
e9DXy31EIHA.2004@TK2MSFTNGP06.phx.gbl...
>
> "Alain Terieur" <alain@terieur.fr> wrote in message
> news:471a4ac2$0$25924$ba4acef3@news.orange.fr...
>> hello
>>
>> J want to inverse the line of a fichier
>> do you know, how do this please
>> thank you
>>
>
> It depends on what you mean. If the source file
> looks like so:
> ABC
> DEF
> GHI
> do you want this:
> CBA
> FED
> IHG
> or this:
> GHI
> DEF
> ABC
>



Re: inverse line fichier by Pegasus

Pegasus
Sun Oct 21 01:55:17 PDT 2007

A simple way would be to do this:
1. Read the input text file one line at a time.
2. Place a running number at the beginning of each line like so:
00000001ABC
00000002DEF
00000003HIJ
3. Write each line to a temporary file.
4. Sort the temporary file in reverse order.
5. Remove the leading 8 character from each line.


"Alain Terieur" <alain@terieur.fr> wrote in message
news:471afd9a$0$5080$ba4acef3@news.orange.fr...
> hello
>
> I want this
> GHI
> DEF
> ABC
>
> thank
>
> "Pegasus (MVP)" <I.can@fly.com> a écrit dans le message de news:
> e9DXy31EIHA.2004@TK2MSFTNGP06.phx.gbl...
>>
>> "Alain Terieur" <alain@terieur.fr> wrote in message
>> news:471a4ac2$0$25924$ba4acef3@news.orange.fr...
>>> hello
>>>
>>> J want to inverse the line of a fichier
>>> do you know, how do this please
>>> thank you
>>>
>>
>> It depends on what you mean. If the source file
>> looks like so:
>> ABC
>> DEF
>> GHI
>> do you want this:
>> CBA
>> FED
>> IHG
>> or this:
>> GHI
>> DEF
>> ABC
>>
>
>



Re: inverse line fichier by Joe

Joe
Sun Oct 21 03:37:31 PDT 2007

"Alain Terieur" <alain@terieur.fr> wrote in message
news:471afd9a$0$5080$ba4acef3@news.orange.fr...
> hello
>
> I want this
> GHI
> DEF
> ABC
>
> thank
>
> "Pegasus (MVP)" <I.can@fly.com> a écrit dans le message de news:
> e9DXy31EIHA.2004@TK2MSFTNGP06.phx.gbl...
>>
>> "Alain Terieur" <alain@terieur.fr> wrote in message
>> news:471a4ac2$0$25924$ba4acef3@news.orange.fr...
>>> hello
>>>
>>> J want to inverse the line of a fichier
>>> do you know, how do this please
>>> thank you
>>>
>>
>> It depends on what you mean. If the source file
>> looks like so:
>> ABC
>> DEF
>> GHI
>> do you want this:
>> CBA
>> FED
>> IHG
>> or this:
>> GHI
>> DEF
>> ABC
>>
>

Read each line using FileSystemObject/TextStream into an array. Write out
each line in reverse order to a new file by starting at the end of the array
and working backwards. Rename and delete the files accordingly.


--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name
.



Re: inverse line fichier by ekkehard

ekkehard
Sun Oct 21 04:22:20 PDT 2007

Pegasus (MVP) schrieb:
> A simple way would be to do this:
> 1. Read the input text file one line at a time.
> 2. Place a running number at the beginning of each line like so:
> 00000001ABC
> 00000002DEF
> 00000003HIJ
> 3. Write each line to a temporary file.
> 4. Sort the temporary file in reverse order.
> 5. Remove the leading 8 character from each line.
>=20
As reversing doesn't involve sorting, a *simple* way could be

Dim oFS : Set oFS =3D CreateObject( "Scripting.FileSystemObject" )
Dim sFSpec : sFSpec =3D ".\revlines.txt"
Dim aLines : aLines =3D Array( "ABC", "DEF", "GHI" )
Dim sText : sText =3D Join( aLines, vbCrLf )

' Create test file; notice trailing vbCrLf
oFS.CreateTextFile( sFSpec, True ).WriteLine sText
' Read test file
sText =3D oFS.OpenTextFile( sFSpec ).ReadAll
' Show
WScript.Echo sText & vbCrLf & "---------"
' To array
aLines =3D Split( sText, vbCrLf )
' Write
Dim oTS : Set oTS =3D oFS.CreateTextFile( sFSpec, True )
Dim nIdx
For nIdx =3D UBound( aLines ) - 1 To 0 Step -1 ' handle trailing vbCrL=
f
oTS.WriteLine aLines( nIdx )
Next
oTS.Close
' Show
sText =3D oFS.OpenTextFile( sFSpec ).ReadAll
WScript.Echo sText & vbCrLf & "---------"

output:

=3D=3D=3D reverseLines: reverse line of file =3D=3D
ABC
DEF
GHI

---------
GHI
DEF
ABC

---------
=3D=3D=3D reverseLines: 0 done (00:00:00) =3D=3D=3D=3D=3D

provided the file isn't too big.
>=20
> "Alain Terieur" <alain@terieur.fr> wrote in message=20
> news:471afd9a$0$5080$ba4acef3@news.orange.fr...
>> hello
>>
>> I want this
>> GHI
>> DEF
>> ABC
>>
>> thank
>>
>> "Pegasus (MVP)" <I.can@fly.com> a =E9crit dans le message de news:=20
>> e9DXy31EIHA.2004@TK2MSFTNGP06.phx.gbl...
>>> "Alain Terieur" <alain@terieur.fr> wrote in message=20
>>> news:471a4ac2$0$25924$ba4acef3@news.orange.fr...
>>>> hello
>>>>
>>>> J want to inverse the line of a fichier
>>>> do you know, how do this please
>>>> thank you
>>>>
>>> It depends on what you mean. If the source file
>>> looks like so:
>>> ABC
>>> DEF
>>> GHI
>>> do you want this:
>>> CBA
>>> FED
>>> IHG
>>> or this:
>>> GHI
>>> DEF
>>> ABC
>>>
>>
>=20
>=20


Re: inverse line fichier by Pegasus

Pegasus
Sun Oct 21 04:51:07 PDT 2007

"ekkehard.horner" <ekkehard.horner@arcor.de> wrote in message
news:471b366d$0$27137$9b4e6d93@newsspool1.arcor-online.net...
Pegasus (MVP) schrieb:
> A simple way would be to do this:
> 1. Read the input text file one line at a time.
> 2. Place a running number at the beginning of each line like so:
> 00000001ABC
> 00000002DEF
> 00000003HIJ
> 3. Write each line to a temporary file.
> 4. Sort the temporary file in reverse order.
> 5. Remove the leading 8 character from each line.
>
As reversing doesn't involve sorting, a *simple* way could be

Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" )
Dim sFSpec : sFSpec = ".\revlines.txt"
Dim aLines : aLines = Array( "ABC", "DEF", "GHI" )
Dim sText : sText = Join( aLines, vbCrLf )

' Create test file; notice trailing vbCrLf
oFS.CreateTextFile( sFSpec, True ).WriteLine sText
' Read test file
sText = oFS.OpenTextFile( sFSpec ).ReadAll
' Show
WScript.Echo sText & vbCrLf & "---------"
' To array
aLines = Split( sText, vbCrLf )
' Write
Dim oTS : Set oTS = oFS.CreateTextFile( sFSpec, True )
Dim nIdx
For nIdx = UBound( aLines ) - 1 To 0 Step -1 ' handle trailing vbCrLf
oTS.WriteLine aLines( nIdx )
Next
oTS.Close
' Show
sText = oFS.OpenTextFile( sFSpec ).ReadAll
WScript.Echo sText & vbCrLf & "---------"

output:

=== reverseLines: reverse line of file ==
ABC
DEF
GHI

---------
GHI
DEF
ABC

---------
=== reverseLines: 0 done (00:00:00) =====

provided the file isn't too big.
======================

By preceding each line with a running number, sorting
the file in reverse order will reverse the order of the lines.
The advantage of using the Windows sort command is
that it can deal with very large files.