Jump to content

Edit .csv file in a grid


Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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