Results 1 to 13 of 13

Thread: cvs

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    cvs

    Hi how can I use CVS? I meant how can I make a cvs file?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: cvs

    You need to download it if you don't already have it.
    http://ftp.gnu.org/non-gnu/cvs/

    Moved.

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: cvs

    - does he mean CSV?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: cvs

    Oh crap... maybe.

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: cvs

    I am glad I gave you that negative rep.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: cvs

    Quote Originally Posted by visualAd
    - does he mean CSV?
    LOL... CVS is pharmacy chain in my town.


    Quote Originally Posted by vbbit
    Hi how can I use CVS? I meant how can I make a cvs file?
    Where is the data come from and what language do you use to program?

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: cvs

    The data will be coming from mysql, and I want to use PHP to program. Is it CVS or CSV? lol.. P told me to download something I have no idea.

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: cvs

    Quote Originally Posted by vbbit
    The data will be coming from mysql, and I want to use PHP to program. Is it CVS or CSV? lol.. P told me to download something I have no idea.
    In that case you better off posting this in PHP forum directly or ask mods to move it.
    And it's CSV - comma separated values (if that's what you need).

  9. #9
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: cvs

    Quote Originally Posted by RhinoBull
    In that case you better off posting this in PHP forum directly or ask mods to move it.
    And it's CSV - comma separated values (if that's what you need).
    Don't you mean ask the mods to move it back?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  10. #10
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: cvs

    CSV = Comma Separated Values.

    They are very easy to create, you just need to ensure you follow the following rules:
    • Each row is terminated with a carriage return / line feed "\r\n" in terms of PHP.
    • Fields are separated by commas.
    • Fields that contain strings with spaces, commas or newlines are enclosed in double quotes.
    • Double quotes inside strings are escaped with two successive double quotes " "" ".
    • The first row may be the column names.


    You could have a simple class that creates it for you:
    PHP Code:
    class CSVCreator
    {
        private 
    $rows = array();
        
        
    /* an array of data to add */
        
    public function addRow($data)
        {
        if (! 
    is_array($data)) {
            throw new 
    Exception('Bad data format');
        }

            
    $this->rows[] = $data;
        }

        
    /* $cols can contain an array of column names */
        
    public function create($cols null)
        {
        
    $ret '';
        
    $rows $this->rows// get a copy of the data

        
    if (is_array($cols)) {
            
    // prepend to the beginning of the arrray
            
    array_unshift($rows$cols);
        }

        foreach (
    $rows as $row) {
            
    $strRow '';
            foreach(
    $row as $col) {
            if (! 
    is_numeric($col)) {
                 
    // enclose all strings in quotes and escape quotes
                
    $col '"' str_replace('"''""'$col) . '"';
            }

                    
    $strRow .= $col ',';
            }

            
    $strRow substr($strRow0, -1); // strip off the last comma if needed
            
    $ret .= $strRow "\r\n";
        }

        
    // strip off last line break \r\n    
        
    $ret substr($ret0, -2);

        return 
    $ret;
        }

    You use it by simply supplying it with the results from a function like mysql_fetch_row().
    PHP Code:
    $csv = new CSVCreator;

    while ((
    $row mysql_fetch_row())) {
        
    $csv->addRow($row);
    }

    echo(
    $csv->create()); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  11. #11

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: cvs

    Oh so after I got that csv file, what is its extension I should save to? and how can I insert it in Ms. Access? or sql server?

  13. #13
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: cvs

    Save it with whatever extension you like. Although as it is a CSV file, using a .csv extension would be the most logical thing to do.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width