Jump to content

csv-file to list


Timo
 Share

Recommended Posts

Hello,

I want to read the data from a csv-file and show it in a list.

That's my code:

$myedit = GUICtrlCreateList ("", 500,50,400,500)

$adressfile = FileOpen("adress.dat",1)

While 1

$line = FileReadLine ($adressfile)

If @error = -1 Then exitloop

GUICtrlSetData($myedit,$line)

Wend

FileClose($adressfile)

I have a lot of trouble with this, e.g. I cant use 1 in FileOpen, only 0 is o.k.

Could someone please give me a short example how to do it the right way?

Thanks,

Timo

Bye...,Timo

Link to comment
Share on other sites

Try this...

$resource = FileOpen("resource.emp", 0)
If $resource = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
While 1
    $line = FileReadLine($resource)
    If @error = -1 Then ExitLoop
    If FileExists($line) Then 
    ContinueLoop
    EndIf
Wend
FileClose($Resource)
Link to comment
Share on other sites

No, that doesn't solve the problem.

This is the code with the GUI-part:

$mylist = GUICtrlCreateList ("", 500,50,400,500)
$resource = FileOpen("adress.dat", 0)
If $resource = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
While 1
    $line = FileReadLine($resource)
    If @error = -1 Then ExitLoop
    If FileExists($line) Then
    ContinueLoop
    GUICtrlSetData($mylist,$line) 
    EndIf
Wend
FileClose($resource)

The file which I want to open is a csv-file with the ";" as separator. Could this be the problem?

Bye...,Timo

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