473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

number of columns

Hi,

How can I know the number of columns of the .csv files? I want to import
them to the database.
Thanks.

Atse
Jul 19 '05 #1
16 2771
atse wrote:
How can I know the number of columns of the .csv files? I want to
import them to the database.


split and ubound maybe

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #2
Can you tell me more detail? Any sample? Thanks.

"William Tasso" <ne****@tbdata.com> wrote in message
news:ux****************@TK2MSFTNGP11.phx.gbl...
atse wrote:
How can I know the number of columns of the .csv files? I want to
import them to the database.


split and ubound maybe

--
William Tasso - http://WilliamTasso.com

Jul 19 '05 #3
On Mon, 06 Oct 2003 19:02:19 GMT, "atse" <du******@yahoo.com> wrote:
Can you tell me more detail? Any sample? Thanks.

"William Tasso" <ne****@tbdata.com> wrote in message
news:ux****************@TK2MSFTNGP11.phx.gbl...
atse wrote:
> How can I know the number of columns of the .csv files? I want to
> import them to the database.


split and ubound maybe


s = "a,b,c,d,e"
a = split(s, ",")
n = ubound(a)

At this point, n should equal 4 since a is a zero based array. Any
more than this, I will have to charge you a consulting fee :)
Jul 19 '05 #4
> >> > How can I know the number of columns of the .csv files? I want to
> import them to the database.

split and ubound maybe


s = "a,b,c,d,e"
a = split(s, ",")
n = ubound(a)

At this point, n should equal 4 since a is a zero based array. Any
more than this, I will have to charge you a consulting fee :)


Here is a signed blank cheque ready for you :-)

Yes, if I can't get the string of one of the rows. but I don't know how to
select [what] from thisfile.csv so that I can get a string with commas:-(

Jul 19 '05 #5
On Tue, 07 Oct 2003 03:56:37 GMT, "atse" <du******@yahoo.com> wrote:
>> > How can I know the number of columns of the .csv files? I want to
>> > import them to the database.
>>
>> split and ubound maybe


s = "a,b,c,d,e"
a = split(s, ",")
n = ubound(a)

At this point, n should equal 4 since a is a zero based array. Any
more than this, I will have to charge you a consulting fee :)


Here is a signed blank cheque ready for you :-)

Yes, if I can't get the string of one of the rows. but I don't know how to
select [what] from thisfile.csv so that I can get a string with commas:-(


Why do you need to have this? Once you have split a line of text into
an array, you will have the VALUES for an INSERT statement.

"INSERT INTO Tbl (cola, colb, colc...) VALUES (" & a(0) & "," & .....

Alternatively, if you are looking to open the CSV file with an ADO
type command, you will nee to find the appropriate connection string,
then issue a statement like...

"SELECT * FROM File.csv" (or something like that).

From the recordset that this yields, you can look at the fields
collection. They will not have a "name" per se, but you can get a
count and cycle through them by number...

rs.fields(0)

Jul 19 '05 #6

"Dan Brussee" <db******@NOSPAMnc.rr.com> wrote in message
news:r7********************************@4ax.com...
On Tue, 07 Oct 2003 03:56:37 GMT, "atse" <du******@yahoo.com> wrote:
>> > How can I know the number of columns of the .csv files? I want to
>> > import them to the database.
>>
>> split and ubound maybe

s = "a,b,c,d,e"
a = split(s, ",")
n = ubound(a)

At this point, n should equal 4 since a is a zero based array. Any
more than this, I will have to charge you a consulting fee :)

Here is a signed blank cheque ready for you :-)

Yes, if I can't get the string of one of the rows. but I don't know how toselect [what] from thisfile.csv so that I can get a string with commas:-(


Why do you need to have this? Once you have split a line of text into
an array, you will have the VALUES for an INSERT statement.

"INSERT INTO Tbl (cola, colb, colc...) VALUES (" & a(0) & "," & .....


The problem is how many cola, colb...., and how many a(0), a(1)? Actually
how can I get the value of a(0)?
Alternatively, if you are looking to open the CSV file with an ADO
type command, you will nee to find the appropriate connection string,
then issue a statement like...

"SELECT * FROM File.csv" (or something like that).

When I do this string, the 16 digit of barcode (9876543210123456) in the
fields all become (9.87654321012345E+15) in the database. Because when it is
inserted into the db, it may be recognized as a number. When I export a text
file, the conversion can't be reversed, and will be a text string
9.87654321012345E+15. How can I do to avoid from this conversion?
From the recordset that this yields, you can look at the fields
collection. They will not have a "name" per se, but you can get a
count and cycle through them by number...

rs.fields(0)


Jul 19 '05 #7
On Tue, 07 Oct 2003 05:21:38 GMT, "atse" <du******@yahoo.com> wrote:

"Dan Brussee" <db******@NOSPAMnc.rr.com> wrote in message
news:r7********************************@4ax.com.. .
On Tue, 07 Oct 2003 03:56:37 GMT, "atse" <du******@yahoo.com> wrote:
>> >> > How can I know the number of columns of the .csv files? I want to
>> >> > import them to the database.
>> >>
>> >> split and ubound maybe
>>
>> s = "a,b,c,d,e"
>> a = split(s, ",")
>> n = ubound(a)
>>
>> At this point, n should equal 4 since a is a zero based array. Any
>> more than this, I will have to charge you a consulting fee :)
>>
>
>Here is a signed blank cheque ready for you :-)
>
>Yes, if I can't get the string of one of the rows. but I don't know howto >select [what] from thisfile.csv so that I can get a string with commas:-(
>


Why do you need to have this? Once you have split a line of text into
an array, you will have the VALUES for an INSERT statement.

"INSERT INTO Tbl (cola, colb, colc...) VALUES (" & a(0) & "," & .....


The problem is how many cola, colb...., and how many a(0), a(1)? Actually
how can I get the value of a(0)?
Alternatively, if you are looking to open the CSV file with an ADO
type command, you will nee to find the appropriate connection string,
then issue a statement like...

"SELECT * FROM File.csv" (or something like that).


When I do this string, the 16 digit of barcode (9876543210123456) in the
fields all become (9.87654321012345E+15) in the database. Because when it is
inserted into the db, it may be recognized as a number. When I export a text
file, the conversion can't be reversed, and will be a text string
9.87654321012345E+15. How can I do to avoid from this conversion?


How about changing the field type to text?

Jul 19 '05 #8
>> >> > How can I know the number of columns of the .csv files? I want to
>> >> > import them to the database.
>> >>
>> >> split and ubound maybe
>>
>> s = "a,b,c,d,e"
>> a = split(s, ",")
>> n = ubound(a)
>>
>> At this point, n should equal 4 since a is a zero based array. Any
>> more than this, I will have to charge you a consulting fee :)
>>
>
>Here is a signed blank cheque ready for you :-)
>
>Yes, if I can't get the string of one of the rows. but I don't know how
to
>select [what] from thisfile.csv so that I can get a string with
commas:-( >

Why do you need to have this? Once you have split a line of text into
an array, you will have the VALUES for an INSERT statement.

"INSERT INTO Tbl (cola, colb, colc...) VALUES (" & a(0) & "," & .....


The problem is how many cola, colb...., and how many a(0), a(1)? Actually
how can I get the value of a(0)?
Alternatively, if you are looking to open the CSV file with an ADO
type command, you will nee to find the appropriate connection string,
then issue a statement like...

"SELECT * FROM File.csv" (or something like that).


When I do this string, the 16 digit of barcode (9876543210123456) in the
fields all become (9.87654321012345E+15) in the database. Because when it

isinserted into the db, it may be recognized as a number. When I export a textfile, the conversion can't be reversed, and will be a text string
9.87654321012345E+15. How can I do to avoid from this conversion?


How about changing the field type to text?


I set the field type of the table in the db is "VARCHAR" (also try "TEXT").
But what about the other point on the previous question? Thanks
The problem is how many cola, colb...., and how many a(0), a(1)? Actually
how can I get the value of a(0)?

Jul 19 '05 #9
On Tue, 07 Oct 2003 15:30:09 GMT, "atse" <du******@yahoo.com> wrote:
>> > How can I know the number of columns of the .csv files? I want to
>> >> >> > import them to the database.
>> >> >>
>> >> >> split and ubound maybe
>> >>
>> >> s = "a,b,c,d,e"
>> >> a = split(s, ",")
>> >> n = ubound(a)
>> >>
>> >> At this point, n should equal 4 since a is a zero based array. Any
>> >> more than this, I will have to charge you a consulting fee :)
>> >>
>> >
>> >Here is a signed blank cheque ready for you :-)
>> >
>> >Yes, if I can't get the string of one of the rows. but I don't knowhow >to
>> >select [what] from thisfile.csv so that I can get a string withcommas:-( >> >
>>
>> Why do you need to have this? Once you have split a line of text into
>> an array, you will have the VALUES for an INSERT statement.
>>
>> "INSERT INTO Tbl (cola, colb, colc...) VALUES (" & a(0) & "," & .....
>
>The problem is how many cola, colb...., and how many a(0), a(1)? Actually
>how can I get the value of a(0)?
>
>> Alternatively, if you are looking to open the CSV file with an ADO
>> type command, you will nee to find the appropriate connection string,
>> then issue a statement like...
>>
>> "SELECT * FROM File.csv" (or something like that).
>>
>
>When I do this string, the 16 digit of barcode (9876543210123456) in the
>fields all become (9.87654321012345E+15) in the database. Because when itis >inserted into the db, it may be recognized as a number. When I export atext >file, the conversion can't be reversed, and will be a text string
>9.87654321012345E+15. How can I do to avoid from this conversion?
>


How about changing the field type to text?


I set the field type of the table in the db is "VARCHAR" (also try "TEXT").
But what about the other point on the previous question? Thanks
>The problem is how many cola, colb...., and how many a(0), a(1)? Actually
>how can I get the value of a(0)?


If you use the recordset access, check out the recordset's field
collection and it's count property...

NumCols = rs.Fields.Count

If you are using the array method, use ubound.

dim a() as string

a = split(txt, ",")

NumCols = ubound(a)

Getting the value of a(0) seems to be pretty obvious...

ValueOfAZero = a(0)
Jul 19 '05 #10
> If you use the recordset access, check out the recordset's field
collection and it's count property...

NumCols = rs.Fields.Count
This is what I want, thanks.

If you are using the array method, use ubound.

dim a() as string
Can't define like this in ASP, it complains with "error 800a0401 Expected
end of statement"

a = split(txt, ",")

What is txt?
NumCols = ubound(a)

Getting the value of a(0) seems to be pretty obvious...

ValueOfAZero = a(0)


Once I get the rs.Fields.Count value, I can get value of rs(0),
rs(1),...rs(rs.Fields.Count). Is it the same with a(0)...?

BTW, I still have the problem of the number with 16 digits in a text file.
In the 15th column there is a barcode in the csv file, like
9876543210123456. When I select it, the rs(14) = "9.87654321012345E+15" is
display. So, when I insert the records into the database, even I set that
field as VARCHAR or TEXT, the value is still 9.87654321012345E+15. Is there
any idea to void this conversion? Thanks a lot.

Atse

Jul 19 '05 #11
atse wrote:
...
So, when I insert the records into
the database, even I set that field as VARCHAR or TEXT, the value is
still 9.87654321012345E+15. Is there any idea to void this
conversion?


I would guess the conversion is being made before it hits the database. the
spec for csv files allows for a string identifier - usually " (double
quote) - but can be anything.

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #12

"William Tasso" <ne****@tbdata.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
atse wrote:
...
So, when I insert the records into
the database, even I set that field as VARCHAR or TEXT, the value is
still 9.87654321012345E+15. Is there any idea to void this
conversion?
I would guess the conversion is being made before it hits the database.

the spec for csv files allows for a string identifier - usually " (double
quote) - but can be anything.
Yes, before inserting into the database, I display them on the page, and it
looks converted. But how can I ADD anything to this number and force it to a
string instead of a number?
--
William Tasso - http://WilliamTasso.com

Jul 19 '05 #13
On Tue, 07 Oct 2003 21:23:40 GMT, "atse" <du******@yahoo.com> wrote:

"William Tasso" <ne****@tbdata.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
atse wrote:
> ...
> So, when I insert the records into
> the database, even I set that field as VARCHAR or TEXT, the value is
> still 9.87654321012345E+15. Is there any idea to void this
> conversion?


I would guess the conversion is being made before it hits the database.

the
spec for csv files allows for a string identifier - usually " (double
quote) - but can be anything.


Yes, before inserting into the database, I display them on the page, and it
looks converted. But how can I ADD anything to this number and force it to a
string instead of a number?
--
William Tasso - http://WilliamTasso.com


As suggested, surround the item in the csv file with quotes.

......., "9876543210123456", .....
Jul 19 '05 #14
> As suggested, surround the item in the csv file with quotes.

......, "9876543210123456", .....


How can I add them to a thousand barcode in a csv file? Any idea?
Thanks,

Atse
Jul 19 '05 #15
On Wed, 08 Oct 2003 01:24:36 GMT, "atse" <du******@yahoo.com> wrote:
As suggested, surround the item in the csv file with quotes.

......, "9876543210123456", .....


How can I add them to a thousand barcode in a csv file? Any idea?
Thanks,

<sigh>
Well, if you are not creating the CSV file, then you would need to do
a transformation using some other method I guess. Maybe a VB app? Any
way of regenerating the CSV file, adding the quotes this time?

Jul 19 '05 #16

"Dan Brussee" <db******@NOSPAMnc.rr.com> wrote in message
news:v6********************************@4ax.com...
On Wed, 08 Oct 2003 01:24:36 GMT, "atse" <du******@yahoo.com> wrote:
As suggested, surround the item in the csv file with quotes.

......, "9876543210123456", .....


How can I add them to a thousand barcode in a csv file? Any idea?
Thanks,

<sigh>
Well, if you are not creating the CSV file, then you would need to do
a transformation using some other method I guess. Maybe a VB app? Any
way of regenerating the CSV file, adding the quotes this time?


OK, if no other choice, I think I have to do so. I will use Excel to edit
the field containing the long number by using CONCATENATE with some symbols
like ** and 123... Anyway, thanks you all!
Atse
Jul 19 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ak | last post by:
Hi! I have a dynaset from a select string and want to insert a bunch of values into the columns/fields. Some of the columns are of type number afaik e.g. number(3) meaning only 3 digits are...
2
by: Neil Zanella | last post by:
Hello, I would like to know whether having a <table> element with two <tr> elements each containing one <td> elements and two <td> elements, respectively, is legal from the point of view of...
13
by: DraguVaso | last post by:
Hi, I need a function that gives me the number of Columns shown in a DataGrid. So I don't need to know the number of columns shown in tha DataSource, because this number can be completely...
5
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to...
3
by: Antonio Maciel | last post by:
Hi. I have a datatable created at runtime that I want to display using a repeater control. The problem is that the number of columns of the datatable can vary. Is there any way to configure the...
5
by: Stephen Poley | last post by:
There are plenty of people around these groups who promote the idea of flexible page design. However, while employing relative units and not fixing column-widths is a big improvement on...
6
by: kilter | last post by:
Anyone know of a routine that will return the number of rows and columns in a matrix?
0
by: sysmanint1 | last post by:
I am a total neophyte at Visual Basic but found the following post and reply from Clint concerning a dynamic range. Also, have never "posted" to a discussion I have made a macro that works on...
8
by: Elfae | last post by:
I have searched high and low for a sample for this, and I just can't find any. Sorry for the length! Background Information The issue revolves around setting up a system-generated increase in...
5
by: imailz | last post by:
Hi all, since I'm forced to switch from Fortran to C I wonder if there is posibility in C: 1) to use implicit loops 2) to parse several variables which number is determined at runtime. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.