Professional Web Applications Themes

number of columns - ASP

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

Sponsored Links
  1. #1

    Default 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


    Sponsored Links
    atse Guest

  2. #2

    Default Re: number of columns

    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 - [url]http://WilliamTasso.com[/url]


    William Tasso Guest

  3. #3

    Default Re: number of columns

    Can you tell me more detail? Any sample? Thanks.

    "William Tasso" <news27tbdata.com> wrote in message
    news:uxslT%239iDHA.2336TK2MSFTNGP11.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 - [url]http://WilliamTasso.com[/url]
    >
    >

    atse Guest

  4. #4

    Default Re: number of columns

    On Mon, 06 Oct 2003 19:02:19 GMT, "atse" <dunggaze> wrote:
    >Can you tell me more detail? Any sample? Thanks.
    >
    >"William Tasso" <news27tbdata.com> wrote in message
    >news:uxslT%239iDHA.2336TK2MSFTNGP11.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 :)


    Dan Brussee Guest

  5. #5

    Default Re: number of columns

    > >> > 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:-(



    atse Guest

  6. #6

    Default Re: number of columns

    On Tue, 07 Oct 2003 03:56:37 GMT, "atse" <dunggaze> 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)



    Dan Brussee Guest

  7. #7

    Default Re: number of columns


    "Dan Brussee" <dbrusseeNOSPAMnc.rr.com> wrote in message
    news:r7h4ovcr233hj0maq4qa8mpr53ft0ium034ax.com...
    > On Tue, 07 Oct 2003 03:56:37 GMT, "atse" <dunggaze> 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) & "," & .....
    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)
    >


    atse Guest

  8. #8

    Default Re: number of columns

    On Tue, 07 Oct 2003 05:21:38 GMT, "atse" <dunggaze> wrote:
    >
    >"Dan Brussee" <dbrusseeNOSPAMnc.rr.com> wrote in message
    >news:r7h4ovcr233hj0maq4qa8mpr53ft0ium034ax.com.. .
    >> On Tue, 07 Oct 2003 03:56:37 GMT, "atse" <dunggaze> 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) & "," & .....
    >
    >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?

    Dan Brussee Guest

  9. #9

    Default Re: number of columns

    >> >> > 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
    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?
    >
    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)?

    atse Guest

  10. #10

    Default Re: number of columns

    On Tue, 07 Oct 2003 15:30:09 GMT, "atse" <dunggaze> 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) & "," & .....
    >> >
    >> >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?
    >>
    >
    >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)


    Dan Brussee Guest

  11. #11

    Default Re: number of columns

    > 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



    atse Guest

  12. #12

    Default Re: number of columns

    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 - [url]http://WilliamTasso.com[/url]


    William Tasso Guest

  13. #13

    Default Re: number of columns


    "William Tasso" <news27tbdata.com> wrote in message
    news:uaLbkYRjDHA.2564TK2MSFTNGP12.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 - [url]http://WilliamTasso.com[/url]
    >
    >

    atse Guest

  14. #14

    Default Re: number of columns

    On Tue, 07 Oct 2003 21:23:40 GMT, "atse" <dunggaze> wrote:
    >
    >"William Tasso" <news27tbdata.com> wrote in message
    >news:uaLbkYRjDHA.2564TK2MSFTNGP12.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 - [url]http://WilliamTasso.com[/url]
    >>
    >>
    >
    As suggested, surround the item in the csv file with quotes.

    ......., "9876543210123456", .....
    Dan Brussee Guest

  15. #15

    Default Re: number of columns

    > 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


    atse Guest

  16. #16

    Default Re: number of columns

    On Wed, 08 Oct 2003 01:24:36 GMT, "atse" <dunggaze> 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?

    Dan Brussee Guest

  17. #17

    Default Re: number of columns


    "Dan Brussee" <dbrusseeNOSPAMnc.rr.com> wrote in message
    news:v607ovkha5egol0nljc04gp7tn0kj75cv14ax.com...
    > On Wed, 08 Oct 2003 01:24:36 GMT, "atse" <dunggaze> 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


    atse Guest

Similar Threads

  1. Restricting number of columns in grid
    By rahma123 in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: November 22nd, 11:14 AM
  2. How to the get to number of retrieved columns?
    By Roman Klimkowicz in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: September 18th, 11:30 PM
  3. How to get the number of retrieved columns when doing a SQL Query
    By Roman Klimkowicz in forum ASP.NET Data Grid Control
    Replies: 4
    Last Post: September 16th, 01:15 PM
  4. Variable number of columns -> problem Update Command
    By Radu Colceriu in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: March 2nd, 02:58 PM
  5. Unknow number of columns in repeater
    By Antonio Maciel in forum ASP.NET General
    Replies: 3
    Last Post: July 2nd, 09:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139