Jump to content
Sign in to follow this  
myspacee

Edit .csv file in a grid

Recommended Posts

myspacee

hello to all,

i've a procedure that generate file.csv :

comune;abitanti;edicole;media;abit-copie,art;complessivi;mod;ultima;media;mediagiorn
Pavia;71214;57;174;409,3;1561;16846,2;12/08/2009;52;561,54
Vigevano;57450;31;483;118,9;947;8176,38;12/08/2009;31,6;272,55
Voghera;38183;30;340;112,3;192;1597,2;12/08/2009;6,4;53,24

I want to give to my user possibility to :

- load this file

- show on video these information, insert in a grid

- give ability to change a value in one cell

- save

Ok, you can say to me 'use Excel', but this is only user part of job,

all data being processed and checked by script when job end.

I can use excel but prefer user Autoit. >_<

There are some function that can help me ?

Thank you for reading,

m.

Edited by myspacee

Share this post


Link to post
Share on other sites
myspacee

obtain to read file and insert in an array :

#include <Array.au3>
#include <file.au3>
Dim $aRecords
dim $main_Array[100]

If Not _FileReadToArray("data.txt",$aRecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf


For $x = 1 to $aRecords[0]

    ;===============================================================================
    ; Example 3 (using an array returned by StringSplit())
    ;===============================================================================
    $avArray = StringSplit($aRecords[$x], ";")
    ;_ArrayDisplay($avArray, "$avArray as a list classes in window", -1, 1)
    

    _ArrayInsert($main_Array, 1, $avArray[1])
    _ArrayInsert($main_Array, 2, $avArray[2])
    _ArrayInsert($main_Array, 3, $avArray[3])
    _ArrayInsert($main_Array, 4, $avArray[4])
    _ArrayInsert($main_Array, 5, $avArray[5])
    _ArrayInsert($main_Array, 6, $avArray[6])
    _ArrayInsert($main_Array, 7, $avArray[7])
    _ArrayInsert($main_Array, 8, $avArray[8])
    _ArrayInsert($main_Array, 9, $avArray[9])
    _ArrayInsert($main_Array, 10, $avArray[10])
    
    _ArrayDisplay($main_Array, "$avArray as a list classes in window")

Next

but this add every file row at the end of array,

how

- build 2d array from file ?

- display all its colums ?

thank you for any info,

m.

Share this post


Link to post
Share on other sites
water

Something like this should give you an 2-dimensional array. Remove "Global $aRecords[5] ..." and the "#cs" and "ce" and it should work for you.

#include <Array.au3>
#include <file.au3>
Global $aRecords[5] = [4,"comune;abitanti;edicole;media;abit-copie,art;complessivi;mod;ultima;media;mediagiorn", _
    "Pavia;71214;57;174;409,3;1561;16846,2;12/08/2009;52;561,54", _
    "Vigevano;57450;31;483;118,9;947;8176,38;12/08/2009;31,6;272,55", _
    "Voghera;38183;30;340;112,3;192;1597,2;12/08/2009;6,4;53,24"]
Global $main_Array[1][1]

#cs
If Not _FileReadToArray("data.txt",$aRecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
#ce

For $x = 1 to $aRecords[0]
    ReDim $main_Array[UBound($main_Array,1)+1][15]
    $avArray = StringSplit($aRecords[$x], ";")
    For $j = 1 To $avArray[0]
        ConsoleWrite($x & " "& $j & @CRLF)
        $main_Array[$x][$j-1] =  $avArray[$j]
    Next
Next
$main_Array[0][0] = UBound($main_Array,1)-1
_ArrayDisplay($main_Array)
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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  

×