Read CSV file

122 views
Skip to first unread message

Kamal Iqramuddin Kamal Arifin

unread,
May 20, 2015, 12:31:16 AM5/20/15
to arrayfi...@googlegroups.com
Hi, 

I am trying to read in CSV file and then do some statistical studies on the data, but I can't seem to find any example on how to read in CSV file. Can someone help me please? If possible, I want to make the first row as the header. Please refer example below.

"No","hours"
"1",3
"2",5
"3",7
"4",18
"5",43
"6",85
"7",91
"8",98
"9",100
"10",130
"11",230
"12",487


Thank you. 

Shehzan Mohammed

unread,
May 20, 2015, 1:11:28 PM5/20/15
to arrayfi...@googlegroups.com, kamaliq...@gmail.com
Hi

I would suggest you to look at a CSV parser or write your own parser.
You will need to parse the data, store it in a host side data structure and then copy it to ArrayFire. There is currently no way to load a file into a device side array directly.

- Shehzan

Kamal Iqramuddin Kamal Arifin

unread,
Jun 1, 2015, 11:01:54 PM6/1/15
to Shehzan Mohammed, arrayfi...@googlegroups.com
Hi, 
Sorry but this is a stupid-simple question. I have created my own parser using standard C++ library. How do I store the data in the host and copy to ArrayFire? 

Thank you.

--
You received this message because you are subscribed to a topic in the Google Groups "ArrayFire Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/arrayfire-users/Nrwy080ShdM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to arrayfire-use...@googlegroups.com.
To post to this group, send email to arrayfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arrayfire-users/4348c0be-d4af-465e-afe6-f17bcab09ff7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks & Regards,

MUHAMMAD KAMAL IQRAMUDDIN BIN KAMAL ARIFIN
Bachelor of Technology,
Information and Communication Technology,
Universiti Teknologi PETRONAS.
Phone  : +601111002423

Brian Kloppenborg

unread,
Jun 2, 2015, 8:18:14 AM6/2/15
to arrayfi...@googlegroups.com


On 06/01/2015 11:01 PM, Kamal Iqramuddin Kamal Arifin wrote:
> Hi,
> Sorry but this is a stupid-simple question. I have created my own parser
> using standard C++ library. How do I store the data in the host and copy
> to ArrayFire?

You can use one of the copy constructors in ArrayFire. For example:

// Create a six-element array on the host
float hA[] = {0, 1, 2, 3, 4, 5};
// Which can be copied into an ArrayFire Array using the pointer copy
// constructor. Here we copy the data into a 2x3 matrix:
array A(2, 3, hA);

The full list of constructors can be found in the documentation:
http://arrayfire.com/docs/group__construct__mat.htm

Kind regards,
Brian
> <mailto:arrayfire-use...@googlegroups.com>.
> To post to this group, send email to
> arrayfi...@googlegroups.com
> <mailto:arrayfi...@googlegroups.com>.
> <https://groups.google.com/d/msgid/arrayfire-users/4348c0be-d4af-465e-afe6-f17bcab09ff7%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> *Thanks & Regards,*
> *
> *
> *_MUHAMMAD KAMAL IQRAMUDDIN BIN KAMAL ARIFIN_*
> Bachelor of Technology,
> Information and Communication Technology,
> Universiti Teknologi PETRONAS/./
> Phone : _+601111002423_
> E-mail : _kamaliq...@gmail.com <mailto:kamaliq...@gmail.com>_
>
> --
> You received this message because you are subscribed to the Google
> Groups "ArrayFire Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to arrayfire-use...@googlegroups.com
> <mailto:arrayfire-use...@googlegroups.com>.
> To post to this group, send email to arrayfi...@googlegroups.com
> <mailto:arrayfi...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/arrayfire-users/CAGg9qKYFznrNSV%3D0gwr5AM5cgPie_FZA1genag%3Dg74gqRLTMsw%40mail.gmail.com
> <https://groups.google.com/d/msgid/arrayfire-users/CAGg9qKYFznrNSV%3D0gwr5AM5cgPie_FZA1genag%3Dg74gqRLTMsw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages