Jump to content

sorting data in file to another file


bogQ
 Share

Recommended Posts

whas up whall night and still cant do it right

i need data from Lista.edit.dat that have lines in it

b00123^test^test2^1^
b00123^test^test2^2^
b00123^test^test2^3^
b00321^test^test2^4^
b00321^test^test2^5^
b00321^test^test2^6^
b00123^test^test2^7^
b00123^test^test2^8^
b00123^test^test2^9^

to sort to Excel.list.dat to b

b00123^test^test2^1^
b00123^test^test2^2^
b00123^test^test2^3^
b00123^test^test2^7^
b00123^test^test2^8^
b00123^test^test2^9^
b00321^test^test2^4^
b00321^test^test2^5^
b00321^test^test2^6^

so that i can write it after that to excel

i need that all b00123 and all other b.... that r in one file to b line under line in next file sorted in one place

everything i try it whas whit no results or with wrong results

can someone pls telme some some other way to do this

this is last what dident worked (not sorted data and i lost some data along the way)

Case $msg = $Button_1
            do
            $file = FileOpen("Lista.edit.dat", 0)
            $file_db = FileOpen("Excel.list.dat", 1)
            If $file = -1 Then
                MsgBox(0, "Error", "Unable to open file.")
                Exit
            EndIf
            
            
            $line8 = FileReadLine($file, 1)
            $file8 = StringSplit($line8, "^")
            $find = $file8[1]
            If $line8 <> "" Then
                Dim $search = "Lista.edit.dat"
                ;next finde in file line that have that name in it
                Dim $aRecords
                If Not _FileReadToArray($search,$aRecords) Then
                EndIf
                For $x = 1 to $aRecords[0]
                Select
                case not StringInStr($aRecords[$x], $find)
                    If $find <> "" Then
                        $file = FileOpen("Lista.edit.dat", 0)
                        $line8 = FileReadLine($file, 1)
                        $file8 = StringSplit($line8, "^")
                        $find = $file8[1]
                        FileClose($file)
                    EndIf
                case StringInStr($aRecords[$x], $find)
                        $file = FileOpen("Lista.edit.dat", 0)
                        $line = FileReadLine($file, $x)
                        $file8 = StringSplit($line, "^")
                        If StringInStr($file8[1], $find) Then
                            FileWriteLine($file_db, $line)
                            FileClose($file_db)
                            FileClose($file)
                            _FileWriteToLine("Lista.edit.dat", $x, "", 1)
                        EndIf
                    EndSelect           
                Next
            EndIf
            Until $line8 = ""
#cs         
            $file_db = FileOpen("Excel.list.dat", 0)
            $oExcel = _ExcelBookOpen(@ScriptDir&$exceldir,1)
            While 1
                $line = FileReadLine($file_db)
                If @error = -1 Then ExitLoop
                MsgBox(0, "Line read:", $line)
                $file4 = StringSplit($line, "^")
                _ExcelWriteCell($oExcel, $file4[3], "b"&($l+7))
                _ExcelWriteCell($oExcel, $file4[5], "e"&($l+7))
                _ExcelWriteCell($oExcel, $file4[6], "i"&($l+7))
                _ExcelWriteCell($oExcel, $file4[4], "m"&($l+7))
                _ExcelWriteCell($oExcel, $file4[10], "c"&($l+7))
                $l = $l+1
            Wend
            FileClose($file)
            FileClose($file_db)
#ce

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

  • Developers

I would use the "good old" sort for that:

RunWait(@ComSpec & " /c Sort < inputfile > outputfile", @ScriptDir, @SW_HIDE)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I would use the "good old" sort for that:

RunWait(@ComSpec & " /c Sort < inputfile > outputfile", @ScriptDir, @SW_HIDE)
ty 4 :)

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...