Jump to content

reading file


 Share

Recommended Posts

Hi, I have a little problem of inexperience with Autoit.

Then I have a. Csv file that I have read and assign to the array. (yes, I know it is not a. standard csv)

The first thing I did was:

_FileReadToArray ("C:\AutoIt\Progetti\Giacenze\Archivi_Miei\oggi.csv",$pippo)

the file is made up of 4/500 lines like the following:

004100;031555;14;1;2,9000;20130329

004100;031556;4;;;20130329

004100;031557;4;;;20130329

004100;032187;1;;;20130329

004100;032249;3;;;20130329

I then I Pravato printing to the console what I've read, it's fine but I can not break down all the changes separated by ";" in as many variables in an array.

for $i = 0 to UBound($pippo)-1

$pluto=StringSplit($pippo,";")

for $t= 1 to 6

$minni[$i][$t]=$pluto[$t]

next $t

ConsoleWrite ($i & " - " & $pippo[$i] & " +++ " & $pluto&@CRLF)

Next

But I do not decompose anything. What could be wrong.

Sorry for my low level.

thanks

Alberto

Italian :

Salve, io ho un problemino di inesperienza con Autoit.

Allora ho un file .csv che devo leggere e assegnare a degli array. (si lo so non è un .csv standard)

La prima cosa che ho fatto è stata :

_FileReadToArray ("C:\AutoIt\Progetti\Giacenze\Archivi_Miei\oggi.csv",$pippo)

il file è composta da 4/500 linee come le seguenti :

004100;031555;14;1;2,9000;20130329

004100;031556;4;;;20130329

004100;031557;4;;;20130329

004100;032187;1;;;20130329

004100;032249;3;;;20130329

Io poi ho pravato a stampare sulla console quello che ho letto, tutto bene ma non riesco a scomporre tutti i cambi separati da ";" in altrettante variabili di un array.

for $i = 0 to UBound($pippo)-1

$pluto=StringSplit($pippo,";")

for $t= 1 to 6

$minni[$i][$t]=$pluto[$t]

next $t

ConsoleWrite ($i & " - " & $pippo[$i] & " +++ " & $pluto&@CRLF)

Next

Ma non mi scompone nulla. Dove sbaglio.

Scusate per il mio basso livello.

Grazie

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Link to comment
Share on other sites

  • Moderators

trescon,

You cannot use ConsoleWrite directly on an array: ConsoleWrite ($i & " - " & $pippo[$i] & " +++ " & $pluto & @CRLF) - you need to break out each element like this: ;)

#include <File.au3>

#include <Array.au3> ; Just for display

Local $Pippo
_FileReadToArray("Test.txt", $Pippo)

_ArrayDisplay($Pippo) ; Just for display

For $i = 0 To UBound($Pippo) - 1
    ConsoleWrite($i & " - " & $Pippo[$i] & @CRLF)
    $Pluto = StringSplit($Pippo[$i], ";")
    For $t = 1 To $Pluto[0]
        ConsoleWrite($Pluto[$t] & " - ")
    Next
    ConsoleWrite(@CRLF)
Next

All clear? :)

M23

P.S. If you are going to add Italian translations to all of your posts, please put them in spoilers like this:

You do this by enclosing the text in [spoi

ler][/spoiler]. ;)

That way the rest of us do nto have to see them. Grazie. ;)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Ok, but my problem is that the content of each line I must decompose to assign to a variable array put him on trial later, not only displayed immediately.

thanks

PS: ok for the spoiler

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Link to comment
Share on other sites

  • Moderators

trescon,

You need to create another array of the correct size and fill it as you go along: ;)

#include <File.au3>

#include <Array.au3>

Local $Pippo
_FileReadToArray("Test.txt", $Pippo)

_ArrayDisplay($Pippo)

Local $Minni[UBound($Pippo)][6]

For $i = 1 To UBound($Pippo) - 1
    $Pluto = StringSplit($Pippo[$i], ";")
    For $t = 1 To $Pluto[0]
        $Minni[$i][$t - 1] = $Pluto[$t]
    Next
    _ArrayDisplay($Minni, "After " & $i)
Next

_ArrayDisplay($Minni, "Final")

Is that better? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Yes, that's much better.

Now I have to try to understand how it works and how to make the most of your example.

thanks

P.S. how do I inseire / activate the spoiler, the list of options not find it.

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Link to comment
Share on other sites

P.S. how do I inseire / activate the spoiler, the list of options not find it.

Between the rubber and the Font combobox you have "Special BBCode" and winthin you will find "Spoiler" but you can directly write

damn, how did Melba23 to show the code tags?

with your text inside ;)

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Between the rubber and the Font combobox you have "Special BBCode" and winthin you will find "Spoiler" but you can directly write

damn, how did Melba23 to show the code tags?

with your text inside ;)

Br, FireFox.

Thanks, found it.

I was looking for as a command visible .....

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

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...