ubuy Posted November 11, 2007 Share Posted November 11, 2007 Well, i have a file .txt in this format. | ΔΡΑ.001 | ΓΡΗΓΟΡΙΑΔΗΣ ΜΙΧΑΗΛ | ΑΓΙΟΣ ΑΘΑΝΑΣΙΟΣ | ΣΟΥΠΕΡ ΜΑΡΚΕΤ | 052072969 | ΔΡΑΜΑΣ | 0,00 | | ΔΡΑ.002 | ΓΙΑΛΑΜΑΣ ΔΗΜΗΤΡΙΟΣ | ΒΕΡΓΙΝΑΣ 13 | | 021874447 | ΔΡΑΜΑΣ | 0,00 | | | ΔΡΑ.004 | ΘΕΟΔΩΡΙΔΟΥ ΝΙΚΗ & ΣΙΑ ΟΕ | ΚΕΦΑΛΑΡΙ | | 082478667 | ΔΡΑΜΑΣ | 0,00 | | | ΔΡΑ.006 | ΠΕΤΡΟΠΟΥΛΟΣ ΓΕΩΡΓΙΟΣ | ΤΕΡΜΑ ΧΡΥΣΟΒΕΡΓΗ | | 046481515 | ΔΡΑΜΑΣ | 0,00 | | I want to delete all the | from the text , justify them at will , change the first field to a number ascending 0001 to whatever , sort them , combine the first field with the second and export them to an other text file called pel.txt This is how i want it to see. I attached 2 files. Before and after. 0001ΓΡΗΓΟΡΙΑΔΗΣ ΜΙΧΑΗΛ ΑΓΙΟΣ ΑΘΑΝΑΣΙΟΣ ΣΟΥΠΕΡ ΜΑΡΚΕΤ 052072969 ΔΡΑΜΑΣ 0,00 0002ΓΙΑΛΑΜΑΣ ΔΗΜΗΤΡΙΟΣ ΒΕΡΓΙΝΑΣ 13 021874447 ΔΡΑΜΑΣ 0,00 0003ΘΕΟΔΩΡΙΔΟΥ ΝΙΚΗ & ΣΙΑ ΟΕ ΚΕΦΑΛΑΡΙ 082478667 ΔΡΑΜΑΣ 0,00 0004ΠΕΤΡΟΠΟΥΛΟΣ ΓΕΩΡΓΙΟΣ ΤΕΡΜΑ ΧΡΥΣΟΒΕΡΓΗ 046481515 ΔΡΑΜΑΣ 0,00 Is this possible ? Can anyone from you make it ? Thanks in advancetext_files.zip Link to comment Share on other sites More sharing options...
Zedna Posted November 11, 2007 Share Posted November 11, 2007 I will not make it for you but I can help you with it. Look into AutoIt helpfile at these functions: _FileReadToArray StringSplit StringReplace StringMid _ArraySort _FileWriteFromArray Try to make your script and post questions when you will be in trouble. Happy AutoIt scripting Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ubuy Posted November 14, 2007 Author Share Posted November 14, 2007 I have no luck. String split does not work for me. Please help me.This my code so far with no luck#include <file.au3>#include <array.au3> ; only for _ArrayDisplay()$sFile = "C:\CL\DATA\winLAGAK1.txt"$file = FileOpen("C:\CL\DATA\winLAGAK1.txt", 0)Dim $text,$newarray$i=0; Read in how many line there areWhile 1 FileReadLine($file) If @error = -1 Then ExitLoop $i=$i+1WendFileClose($file); Read file to array and delte first 10 recordsIf Not _FileReadToArray($sFile, $text) Then MsgBox(4096, "Error", " Error reading text file to Array error:" & @error) ExitEndIf$i=0For $i = 1 to 30 step 1_ArrayDelete($text,0)$i=$i+1Next;DELETE LAST RECORDS_ArrayDelete($text,1131-16)_ArrayDelete($text,1131-15)_ArrayDelete($text,1131-14)$array =StringSplit ( $TEXT, @TAB )_ArrayDisplay($ARRAY, "Debug: $text")_ArrayDisplay($TEXT, "Debug: $text") Link to comment Share on other sites More sharing options...
ubuy Posted November 23, 2007 Author Share Posted November 23, 2007 Anyone? Please help... How can i create a multidimensional array so i can split my text line to fields ? Or maybe how can i split my text line to mdb fields ? Link to comment Share on other sites More sharing options...
MadBoy Posted November 23, 2007 Share Posted November 23, 2007 Anyone? Please help... How can i create a multidimensional array so i can split my text line to fields ? Or maybe how can i split my text line to mdb fields ? Work with $temporary_string to get the output into the file that you desired, i don't have time for that expandcollapse popup#include <GUIConstants.au3> #include <array.au3> #include <file.au3> #include <String.au3> Global $file_to_read = "C:\before.txt" Global $file_to_put = "C:\after.txt" Global $array_file, $array_output_file[1] _FileReadToArray($file_to_read, $array_file) For $a = 1 To $array_file[0] $temporary_array = StringSplit($array_file[$a], "|") If $temporary_array[0] = 10 Then $temporary_string = _NumberConversion($a, $array_file[0]) & @TAB & $temporary_array[2] & @TAB & $temporary_array[3] & @TAB & $temporary_array[4] & @TAB & $temporary_array[5] & @TAB & _ $temporary_array[6] & @TAB & $temporary_array[7] & @TAB & $temporary_array[8] & @TAB & $temporary_array[9] & @TAB & $temporary_array[10] ConsoleWrite(@CR & $temporary_string) If $temporary_string <> "" Then _ArrayAdd($array_output_file, $temporary_string) _FileWriteFromArray($file_to_put, $array_output_file) EndIf Else ; Ignore EndIf Next $array_output_file[0] = UBound($array_output_file) - 1 Func _NumberConversion($temp_number, $max_digits) If StringLen($temp_number) <> StringLen($max_digits) Then Do $temp_number = _StringInsert("" & $temp_number & "", "0", 0) If @error Then MsgBox(0, 1, @error) Until StringLen($temp_number) = StringLen($max_digits) Return $temp_number Else Return $temp_number EndIf EndFunc ;==>_NumberConversion My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now