DaLiMan Posted July 7, 2004 Share Posted July 7, 2004 Is there a trick for my problem below? I have a .txt file which actually has 2 colums of text: Text-A Text-1 Text-B Text-2 Text-C Text-3 Text-D Text-4 Text-E Text-5 Text-F Text-6 Text-G Text-7 etc... Now I have to copy and paste each text in a different field and then do the same for the next line. Is there a way this could be done with _FileReadToArray and then make a new line after Text-A/B/C.... somehow? Link to comment Share on other sites More sharing options...
ezzetabi Posted July 7, 2004 Share Posted July 7, 2004 What about split the string before at the @lf and the second time at the spaces? Link to comment Share on other sites More sharing options...
DaLiMan Posted July 7, 2004 Author Share Posted July 7, 2004 Dont quite follow. _FileReadToArray does the chop up by the @CR of I'm not mistaken. So actually after this funtion I like to split the string at the SPACES. But I can't seem to figure out how to make this work. Here's what I have for testing: #include <file.au3> Global $AARRAY Global $AARRAY2 ; perform the _FileReadtoArray function and when the returncode = 1 show the number of records and all record contents If _FileReadToArray("C:\Documents and Settings\Default User\Local Settings\Temp\ArtNR.txt", $AARRAY) Then MsgBox(0, "Array Output records", $AARRAY[0]) Run("Notepad.exe", "", @SW_MAXIMIZE) For $X = 1 To $AARRAY[0] $aarray2 = StringSplit(StringReplace($aarray, " ", @LF), @LF) For $X2 = 1 To $AARRAY2[0] WinActivate("Untitled - Notepad", "") Sleep(750) Send($AARRAY2[$X2] & "{ENTER}") Next Next Else ; returncode was 0 so the function reported that the file doesn't exist MsgBox(0, "Error", "Error from Function") EndIf Exit Link to comment Share on other sites More sharing options...
Developers Jos Posted July 7, 2004 Developers Share Posted July 7, 2004 just try: $aarray2 = StringSplit(StringReplace($aarray, " ", @LF), @LF & " ") 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 More sharing options...
DaLiMan Posted July 7, 2004 Author Share Posted July 7, 2004 Hi JdeB, Just tried your code but nothing is SEND but empty lines... Global $AARRAY Global $AARRAY2 ; perform the _FileReadtoArray function and when the returncode = 1 show the number of records and all record contents If _FileReadToArray("C:\Documents and Settings\Default User\Local Settings\Temp\ArtNR.txt", $AARRAY) Then MsgBox(0, "Array Output records", $AARRAY[0]) Run("Notepad.exe", "", @SW_MAXIMIZE) For $X = 1 To $AARRAY[0] $aarray2 = StringSplit(StringReplace($aarray, " ", @LF), @LF & " ") For $X2 = 1 To $AARRAY2[0] WinActivate("Untitled - Notepad", "") Sleep(750) Send($AARRAY2[$X2] & "{ENTER}") Next Next Else ; returncode was 0 so the function reported that the file doesn't exist MsgBox(0, "Error", "Error from Function") EndIf Link to comment Share on other sites More sharing options...
Developers Jos Posted July 7, 2004 Developers Share Posted July 7, 2004 (edited) sorry... didn't properly look at what you changed... your change should already have worked.. Can you show a few records and how you want them to split ? Edited July 7, 2004 by JdeB 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 More sharing options...
Developers Jos Posted July 7, 2004 Developers Share Posted July 7, 2004 (edited) Had a closer look at your code this time and think i found your issue:$aarray2 = StringSplit(StringReplace($aarray[$X], " ", @LF), @LF) Edited July 7, 2004 by JdeB 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 More sharing options...
DaLiMan Posted July 7, 2004 Author Share Posted July 7, 2004 (edited) Sure, A [very] small piece of the .txt file looks like this; 99077 1500023 19055 1500046 19056 1500127 19057 1500143 19058 1500317 16312 1501511 19048 1502315 Now I have to manually copy & paste the first number [99077] in a field and the second number [1500023] in another field. Then with ENTER add this data in our database and do the same thing all over again for the next line and so on..... PS: I use .txt because [i think] _FileReadToArray can't use .xls Edited July 7, 2004 by DaLiMan Link to comment Share on other sites More sharing options...
Developers Jos Posted July 7, 2004 Developers Share Posted July 7, 2004 (edited) PS: I use .txt because [i think] _FileReadToArray can't use .xlsFilename shouldn't matter...... Did you see the post above your last post ? Edited July 7, 2004 by JdeB 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 More sharing options...
DaLiMan Posted July 7, 2004 Author Share Posted July 7, 2004 Sorry, didn't see your reply. Added your piece and now there is really no change from the original File reading script. It just reads the file and pastes this in the same way as it was. I don't get it. Link to comment Share on other sites More sharing options...
DaLiMan Posted July 7, 2004 Author Share Posted July 7, 2004 I discovered the space between the number is a TAB. But the line below stil isn't the change I was looking for. $aarray2 = StringSplit(StringStripWS($aarray[$X], 3), @LF) or $aarray2 = StringSplit(StringReplace($aarray[$X], "Chr(9)", @LF), @LF) Link to comment Share on other sites More sharing options...
Developers Jos Posted July 7, 2004 Developers Share Posted July 7, 2004 and what about : $aarray2 = StringSplit($aarray[$X], @TAB) 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 More sharing options...
DaLiMan Posted July 7, 2004 Author Share Posted July 7, 2004 (edited) and what about : $aarray2 = StringSplit($aarray[$X], @TAB)Wonderful !!! You're the greatest!!! My life just got so much better....... And just in time cause i'm going home now so I can sleep well tonight. I'm gonna rock this place tomorrow, they won't know what hit them! Edited July 7, 2004 by DaLiMan 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