Does anyone have a good way of importing a csv file into an object?
Entity1,123,22,red,blue
Entity2,123,22,red,blue
Entity3,123,22,red,blue
Entity4,123,22,red,blue
Entity5,123,22,red,blue
Currently I am spliting the data and then creating two for loops to loop
through the rows and then each column to assign the corresponding object
property. 2 1239
What about this option:
Add a new constructor to your object that takes a string in like so:
public void MyObject(string PropertiesCSV)
{
string[] ListOfProperties = PropertiesCSV.Split(",")
for(int i=0;i<ListOfProperties.GetUpperBound(0);i++)
{
this.var1 = ListOfProperties[i];
...
this.var99 = ListOfProperties[i]
}
}
Then all you need is one loop for each line in the CSV. I know this doesn't
exactly change your problem, it just shifts where the inner loop sits.
Hope this has been of some help.
Greg
"MFRASER" <mf*****@henwoodenergy.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Does anyone have a good way of importing a csv file into an object?
Entity1,123,22,red,blue Entity2,123,22,red,blue Entity3,123,22,red,blue Entity4,123,22,red,blue Entity5,123,22,red,blue
Currently I am spliting the data and then creating two for loops to loop through the rows and then each column to assign the corresponding object property.
Hi,
Take a look at http://www.opennetcf.org/Csv.asp
I'm using it and it works great.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"MFRASER" <mf*****@henwoodenergy.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Does anyone have a good way of importing a csv file into an object?
Entity1,123,22,red,blue Entity2,123,22,red,blue Entity3,123,22,red,blue Entity4,123,22,red,blue Entity5,123,22,red,blue
Currently I am spliting the data and then creating two for loops to loop through the rows and then each column to assign the corresponding object property.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: qwweeeit |
last post by:
The pythonic way of programming requires, as far as I know, to spread a
big application in plenty of more manageable scripts, using import or
from ... import to connect the various modules.
In...
|
by: serge |
last post by:
Using some VB sample code on the Internet I have the following
that works well and exports a set of records to an XML file:
Dim oCmd, sSQL, oDom
Set oDom =...
|
by: Richard Holliingsworth |
last post by:
Hello:
Thanks for your quick response.
I'm trying to import a new Excel file into an A2K table and it's
truncating the data. One of the Excel columns is a text field that can
be up to 2000...
|
by: Dan |
last post by:
Hi, just ran into my first instance of a backend Access97 database not
compacting. I'm getting the "MSACCESS.EXE has generated errors.." message on
compact.
I've narrowed it down to the largest...
|
by: Edward S |
last post by:
I budget for a Project in an Excel sheet as illustrated below. The
months below are usually a 2 year period i.e. 24 months, though it
could be over 24 months depending upon a Project. I then...
|
by: Aladdin |
last post by:
I have an MS Access form on which I have a listbox listing tables in
that database. I want to be able to click on any of those tables and
view its contents on the same form using subforms or any...
|
by: cheryl |
last post by:
I am relatively new to programming in Access for a multi user
environment, and am having trouble figuring out if there is a way to
accomplish one of our user requests.
I am working on a multi...
|
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte...
|
by: larry |
last post by:
Ok I'm a Python noob, been doing OK so far, working on a data
conversion program and want to create some character image files from
an 8-bit ROM file.
Creating the image I've got down, I open...
|
by: rs387 |
last post by:
Hi,
I've found the following behaviour on importing a variable from a
module somewhat odd. The behaviour is identical in Python 2.5 and
3.0b2.
In summary, here's what happens. I have a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |