Jump to content

make array from textfile and split them.


Jack023
 Share

Recommended Posts

Hey all,

I have some information in a textfile listed with:

information1:information2

information3:information4

etc...

now i want make a a dimensiol array array[0][0]

then second line 

array[1][1].

This is possible i think?

Could somebody help me , let we say the textfile is named: information.txt

Thanks in advance

Link to comment
Share on other sites

Can't edit it, but i want: array [0] is nothing

Information1:information2

I want information1 in array[1] and ifirmation 2 in array[2]

Information3:Information4

Informatiom3 in array[3] etc

But not the ' : ' symbol

All read from a textfile!

Thanks in advance ,

Link to comment
Share on other sites

Here:

#include <Array.au3>
$sString = FileRead(@DesktopDir & "\some.txt")
$aData = StringSplit($sString, @LF & ":")

; Remove @CR's
For $i = 1 To UBound($aData) - 1
    $aData[$i] = StringStripCR($aData[$i])
Next
_ArrayDisplay($aData)

Returns:

[0]|4
[1]|information1
[2]|information2
[3]|information3
[4]|information4
 

Where desktop file = some.txt contains:

information1:information2
information3:information4

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

or, returning a base 0 array:

#include <Array.au3>
$sString = FileRead(@DesktopDir & "\some.txt")
;~ $aData = StringSplit($sString, @LF & ":")

; Remove @CR's
;~ For $i = 1 To UBound($aData) - 1
;~  $aData[$i] = StringStripCR($aData[$i])
;~ Next
;~ _ArrayDisplay($aData)

$aData = StringRegExp($sString,"[^:\v]+",3)
_ArrayDisplay($aData)
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Can be done with >_CSVSplit First read file and then pass the data to the function with the delimiter changed to colon. That's if you want  a 2D array. I'm not sure what a a dimensiol array array is is. Maybe it's not what you want.

Oops wrong function name - changed.

Edited by czardas
Link to comment
Share on other sites

I'm not sure what a a dimensiol array array is is.

How do you call these pink pills in your area? :think:

 

Maybe it's not what you want.

Sure!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

#include <Array.au3>


;array read

$sString = FileRead(@DesktopDir & "\5faccs.txt")
$aData = StringSplit($sString, @LF & ":")

; Remove @CR's
For $i = 1 To UBound($aData) - 1
    $aData[$i] = StringStripCR($aData[$i])
Next

fixed it, only need help with my loop, but its a private script , so i dont want bring it in public!

If someone can add me at skype: jack.jack023

i would really appreciate that !

Edited by Jack023
Link to comment
Share on other sites

Where did you put the message box? When the loop has finished, $i is greater than the maximum index of the array. If you also then add 1, $i will be greater by 2 counts. You should get an error about array dimension range exceeded. Put the msgbox inside the loop and do not add 1.


Oh you deleted your question. Now my responce makes no sense.

Edited by czardas
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...