Jump to content

Issue with _filereadtoarray


Milas
 Share

Recommended Posts

  • Moderators

Milas,

You are adding an extra "," at the end of each line. As this is not present in the first line of the files (the titles), the function fails because there are dissimilar numbers of fields in the lines - you should be getting error set to 3 in the MsgBox.

Change the code to read as follows and all will work:

Func Submit($array)
    If Not FileExists($sDataFilePath) Then
        FileWriteLine($sDataFilePath, "Date,Rank,Last,First,Middle,Serial,ECN,MAC,Clinical,Make,Model,Department")
    EndIf

    For $i = 0 To 11
        Switch $i
            Case 0
                FileWrite($sDataFilePath, "" & @MON & "/" & @MDAY & ",")
            Case 1 To 10
                FileWrite($sDataFilePath, $array[0][$i] & ",")
            Case 11
                FileWrite($sDataFilePath, $array[0][$i])
        EndSwitch
    Next
    FileWriteLine($sDataFilePath, "")

EndFunc   ;==>Submit

Now there is no final "," and the function works as you expected.

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

so I did as u said but the func that I have reading the file still only creates it as a 1D array. I try to use the comma as a delimiter to separate everything in to their own cell to make it a 2d array but errors out every time

 

thank you for your help by the way I really appreciate it

 

 

 

Link to comment
Share on other sites

  • Moderators

Milas,

It works for me when I test - I get a nice 2D array displayed. Can you please post an example of the csv file that you create so I can take a look.

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

Thank you for your help. your response made me realize it was the csv file I was using witht he old data in it. i deleted that csv file and had it create a new one. everything works perfectly with the new file. Thank you very much. If no one tells you that you are amazing just remember this day that i told you

you are amazing

Edited by Milas
Link to comment
Share on other sites

  • Moderators

Milas,

the csv file I was using witht he old data in it

I thought that might be the case - hence my request. Delighted it now works and glad I could help,

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

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

×
×
  • Create New...