Sign in to follow this  
Followers 0
DaLiMan

FileReadToArray and @CRLF

13 posts in this topic

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?

Share this post


Link to post
Share on other sites



What about split the string before at the @lf and the second time at the spaces?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Had a closer look at your code this time and think i found your issue:

$aarray2 = StringSplit(StringReplace($aarray[$X], " ", @LF), @LF)

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (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..... :ph34r:

PS: I use .txt because [i think] _FileReadToArray can't use .xls

Edited by DaLiMan

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

PS: I use .txt because [i think] _FileReadToArray can't use .xls

Filename shouldn't matter......

Did you see the post above your last post ?

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sorry, didn't see your reply. :ph34r:

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.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

and what about :

$aarray2 = StringSplit($aarray[$X], @TAB)

Wonderful !!! :(

You're the greatest!!!

My life just got so much better.......:ph34r:

And just in time cause i'm going home now so I can sleep well tonight. :lol:

I'm gonna rock this place tomorrow, they won't know what hit them!

Edited by DaLiMan

Share this post


Link to post
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
Sign in to follow this  
Followers 0