Guys,
I have a text file which is comma delimited and information. Each information is ended by end of line and started again with comma delimited i.e.
1,2,3,a,4
2,s,4,5,6,7,8,h
2,3,5,7,f,h,j,d,d
What i need to do is pick a line and then put this in a array. then reference it like this:
ar(1)=1
ar(2)=2
.
.
.
ar(5)=4
now i dont want all the data to dumped into sql table.
i pick 1,3 and 5 to dumped into a sql table.
can some tell me how to do this in a very professional and optmized way.
Resources:
Text file comma delimited
Visual Basic project
SQL server database
8 4046
Well, taking one thing at a time, splitting the input into an array is very simple using the Split statement, if you don't have commas in your data.
So, does your data contain commas (inside the fields, I mean)?
Or to be more precise, can you data contain commas? You have to be able to cope with what's possible, not just what shows up in one sample.
If you do have commas in your fields (which is perfectly acceptable in CSV format) then you can still split it up, obviously - it'll just require a bit more programming effort.
Yes its a comma delimited file....let me how to split them into array. then pick what i want to push it into a SQL table. I am using SQL server 2000.
Well, taking one thing at a time, splitting the input into an array is very simple using the Split statement, if you don't have commas in your data.
So, does your data contain commas (inside the fields, I mean)?
Or to be more precise, can you data contain commas? You have to be able to cope with what's possible, not just what shows up in one sample.
If you do have commas in your fields (which is perfectly acceptable in CSV format) then you can still split it up, obviously - it'll just require a bit more programming effort.
Yes its a comma delimited file....let me how to split them into array. then pick what i want to push it into a SQL table. I am using SQL server 2000.
hi
that's relative simple
say:
strInput="2,s,4,5,6,7,8,h"
Arr=Split(strInput,",")
then....
Item1=Arr(0)
Item2=Arr(1)
etc..
Yes its a comma delimited file....let me how to split them into array. then pick what i want to push it into a SQL table. I am using SQL server 2000.
The point I was making is that if your data is comma delimited, then it complicates things if a comma appears as part of the data. Think about it.
Here's a quick example to illustrate what I mean. Let's say you have three fields:
ID: 12345
Name: Nurk, Fred
Age: 53
If that is placed in a comma delimited file, you might have:
If you then use Split to pull the record apart at each comma, you will end up with 4 fields, not 3.
There are ways of dealing with this, of course. I was just trying to ascertain whether they might be required.
The point I was making is that if your data is comma delimited, then it complicates things if a comma appears as part of the data. Think about it.
Here's a quick example to illustrate what I mean. Let's say you have three fields:
ID: 12345
Name: Nurk, Fred
Age: 53
If that is placed in a comma delimited file, you might have:
If you then use Split to pull the record apart at each comma, you will end up with 4 fields, not 3.
There are ways of dealing with this, of course. I was just trying to ascertain whether they might be required.
if you know which fields (array-members) they are, you can always glue them together with a comma.
if you know which fields (array-members) they are, you can always glue them together with a comma.
True. But only if you know. In this example, what if the name didn't have a comma? What if there were 18 fields which might or might not contain commas? It would be better to separate them using a method which doesn't break until the end of the field.
CSV format handles it all, with text delimiters and so on. It's nothing particularly difficult, just not worth bothering about if the data in this case is all just single-character stuff (as in the sample), with no in-field commas possible. In that case, the simple Split statement is definitely the way to go.
True. But only if you know. In this example, what if the name didn't have a comma? What if there were 18 fields which might or might not contain commas? It would be better to separate them using a method which doesn't break until the end of the field.
CSV format handles it all, with text delimiters and so on. It's nothing particularly difficult, just not worth bothering about if the data in this case is all just single-character stuff (as in the sample), with no in-field commas possible. In that case, the simple Split statement is definitely the way to go.
absolutely
but in this case it seems a simple split-function will do
as the first message indicates a comma separated input of characters.
1,2,3,a,4
2,s,4,5,6,7,8,h
2,3,5,7,f,h,j,d,d
hi
that's relative simple
say:
strInput="2,s,4,5,6,7,8,h"
Arr=Split(strInput,",")
then....
Item1=Arr(0)
Item2=Arr(1)
etc..
great,
this definetely help? now how do i push the info in SQL table. i am using sql server 2000.
say i have a table: test in database: main
txt: 1,2,3,dump,E3929H,-12,0,0,0
usnig your method i have them in array.
now how do create a connection to database, and push the info in the table test?
a sample code will definetely help
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Josef Wolf |
last post by:
Hello!
Is it possible to have CVS-style command line options with the optparse
module? I could get as far as:
import sys
from optparse import OptionParser, OptionGroup
parser =...
|
by: Ethan |
last post by:
Im doing perl for an online store and wondering if someone knew a way (a
script) to get my text files in to my database?
|
by: news |
last post by:
Our production database in an exported textfil runs about 60 MB.
Compressed that's about 9 MB.
I'm trying to import the export into another machine running FC3 and
mySQL 11.18, and it appears as...
|
by: Pir8 |
last post by:
I have a complex xml file, which contains stories within a magazine. The
structure of the xml file is as follows:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<magazine>
<story>...
|
by: AustinClark |
last post by:
During login and logout, the workstations on my network dump some info into a text file. Part of this info is the current date and time, rendered by doing "echo %date%,%time%" at the command line.
...
|
by: sebzzz |
last post by:
Hi,
I work at this company and we are re-building our website: http://caslt.org/.
The new website will be built by an external firm (I could do it
myself, but since I'm just the summer student...
|
by: Eric Wertman |
last post by:
I have a set of files with this kind of content (it's dumped from WebSphere):
]
|
by: Luis Zarrabeitia |
last post by:
I need to parse a file, text file. The format is something like that:
TYPE1 metadata
data line 1
data line 2
....
data line N
TYPE2 metadata
data line 1
....
|
by: =?Utf-8?B?TTFpUw==?= |
last post by:
I’m trying to parse out Amazon S3 server logs which are space delimited.
However date fields are in the following form:
When I try to use the following code to split the record on the...
|
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: 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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |