Jump to content

CSV file data assigned to individual Varibles


 Share

Recommended Posts

I use a program called Paradox. I have already programed in ObjectPal a way to create a CSV file from my tables. What I need is a way to read my CSV file (_FileReadToArray) then assign the data to individual variables. I need to take those variables, and assign them to field names using the #include <IE.au3> library. (Already made this script). However if I can not assign individual data from the CSV file array I create I can not transfer the information the field names on the claim processing page. I am a TV technician trying to automatically submit information from Paradox (my companies application) to the manufacture website for claim submission after a repair is completed under warranty. I spend to much time typing the same information from one program to the manufactures website then it takes repairing the entire TV set.

Example of CSV file generated by Paradox. Delimiters are pipes "|", lets call the CSV file Data.csv

 

Name|Address|Phone|Manafacture|Model|Serial|Repair|

John|123 Apple Tree|123-456-7890|Sony|KDL46|0123|Replaced Main|

 

Now, I have searched , and read many examples on this forum the past week on CSV files and autoit (There's a lot). CSV-Editor V0.8.au3 by Funkey is to complicated for me to understand being new to autoit/ or python but that was the best examples of anything CSV I could find.  All the other examples I seen , and tried only split the CSV file into rows of data.  I need to be able to assign a variable as followed.

$varName = (location of this data inside the array for Name)

$varAddress =  (location of this data inside the array for Address)

$varPhone =  (location of this data inside the array for Phone)

If anyone could help me, I would offer free TV diagnosis , and repairs (if parts are cheap enough) here in the Dallas TX area.

 

-Josh

 

 

Link to comment
Share on other sites

I found this script that displays from a loop individual data after you close first windows that displays all content in CSV file. But how would I assign individual data to a variable using this method?

 

#include <array.au3>
#include <file.au3>

Dim $oneDarray
_FileReadToArray(@ScriptDir & "" & "\Data.csv", $oneDarray,$FRTA_NOCOUNT)
For $y =0 To UBound($oneDarray) -1
   $columnsCounter = stringsplit($oneDarray[$y],",")
   _ArrayDisplay($columnsCounter, "1D array - count", Default, 8)
   MsgBox(0,"",UBound($columnsCounter))
   For $x= 1 To UBound($columnsCounter)-1
      Dim $RowCounter=$columnsCounter[$x]
      MsgBox(0,"",$RowCounter)

   Next
Next

Link to comment
Share on other sites

Each item in the array is a variable for example:

#include <array.au3>
#include <file.au3>

Global $2dArray
_FileReadToArray(@ScriptDir & "" & "\Data.csv", $2dArray,$FRTA_NOCOUNT,"|")
_ArrayDisplay($2dArray)
For $i =1 To UBound($2dArray) -1
    MsgBox(0, '', _
    "Name = " & $2dArray[$i][0] & @CRLF & _
    "Address = " & $2dArray[$i][1] & @CRLF & _
    "Phone = " & $2dArray[$i][2] & _
    "Manufacturer = " & $2dArray[$i][3] & @CRLF & _
    "Model = " & $2dArray[$i][4] & @CRLF & _
    "Serial = " & $2dArray[$i][5] & @CRLF & _
    "Repair = " & $2dArray[$i][6])
Next

 

Link to comment
Share on other sites

25 minutes ago, Subz said:

Each item in the array is a variable for example:

#include <array.au3>
#include <file.au3>

Global $2dArray
_FileReadToArray(@ScriptDir & "" & "\Data.csv", $2dArray,$FRTA_NOCOUNT,"|")
_ArrayDisplay($2dArray)
For $i =1 To UBound($2dArray) -1
    MsgBox(0, '', _
    "Name = " & $2dArray[$i][0] & @CRLF & _
    "Address = " & $2dArray[$i][1] & @CRLF & _
    "Phone = " & $2dArray[$i][2] & _
    "Manufacturer = " & $2dArray[$i][3] & @CRLF & _
    "Model = " & $2dArray[$i][4] & @CRLF & _
    "Serial = " & $2dArray[$i][5] & @CRLF & _
    "Repair = " & $2dArray[$i][6])
Next

 

Thank you Subz. It's so simple when explained.

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