Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
CSV file help
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Lucky Khoza  
View profile  
 More options Nov 12 2012, 2:54 am
From: Lucky Khoza <mrkh...@gmail.com>
Date: Mon, 12 Nov 2012 09:54:25 +0200
Local: Mon, Nov 12 2012 2:54 am
Subject: [erlang-questions] CSV file help

Hi Erlang Developers,

Where do i start in terms of reading CSV file, because i tried to use this
rountines:

{ok,String} = file:open("produce.csv",read).
io:get_line(String, ' ').

but when i used this rountine: io:get_line(String,' ') to read each line i
got this tuple: {error,terminated},

And the file i'm trying to read is like this:

"Supplier ID","Product Code","Product Description","Delivery Date","Unit
Price","Number of Units"
15,1101,"Apples 1kg Golden Delicious. The sweetest Apples! Always a
favourite. Love, Mrs. Hollingberry","2012/02/15",1505,5

Thanks in advance for your help.

Kindest Regards
Lucky

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bengt Kleberg  
View profile  
 More options Nov 12 2012, 3:05 am
From: Bengt Kleberg <bengt.kleb...@ericsson.com>
Date: Mon, 12 Nov 2012 09:04:52 +0100
Local: Mon, Nov 12 2012 3:04 am
Subject: Re: [erlang-questions] CSV file help
Greetings,

The documentation page for io:file/2 says that the second argument
should be a list of atoms. Like this: [read].
If {ok, String} matches, then you are probably just lucky.

bengt

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Uvarov  
View profile  
 More options Nov 12 2012, 7:20 am
From: Michael Uvarov <free...@gmail.com>
Date: Mon, 12 Nov 2012 15:20:16 +0300
Local: Mon, Nov 12 2012 7:20 am
Subject: Re: [erlang-questions] CSV file help
Hi,

There are few libraries for CSV parsing.
I wrote this one. https://github.com/arcusfelis/csv_parser

--
Best regards,
Uvarov Michael
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jesper Louis Andersen  
View profile  
 More options Nov 12 2012, 7:30 am
From: Jesper Louis Andersen <jesper.louis.ander...@erlang-solutions.com>
Date: Mon, 12 Nov 2012 13:30:40 +0100
Local: Mon, Nov 12 2012 7:30 am
Subject: Re: [erlang-questions] CSV file help

On Nov 12, 2012, at 8:54 AM, Lucky Khoza <mrkh...@gmail.com> wrote:

> Hi Erlang Developers,

> Where do i start in terms of reading CSV file, because i tried to use this rountines:

> {ok,String} = file:open("produce.csv",read).
> io:get_line(String, ' ').

There are two problems here:

first, file:open/2 should be called appropriately and Bengt writes. Second, the binding {ok, String} should rather be {ok, IoDevice} in order to be more precise. The IO device needs to be used to read out data from the file in question. Look at the call file:read_line/2.

The io:get_line/2 call is probably ok, but I would prefer file:read_line/2 since it does not have to be given a prompt. Speaking of prompt, the value '' is not a string but an (empty) atom. In Erlang, you can't interchange ' and " like many other languages (almost) allows you to.

The {error, terminated} is probably because your IoDevice was not opened correctly and thus the call fails.

Jesper Louis Andersen
  Erlang Solutions Ltd., Copenhagen

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »