Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8057803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:09:04+00:00 2026-06-05T09:09:04+00:00

I have a csv, generated with Open Office Spreadsheet, separator is comma, text wrapper

  • 0

I have a csv, generated with Open Office Spreadsheet, separator is comma, text wrapper is “.

I want just to columns in my spreadsheet, as it is some key-value list,
like:

a -> b
aa -> bb
aaa -> bbb

so my spreadsheet has just two columns, each row containing a key-value pair, each key in a cell, each value in a cell. But when I use

if ($_FILES ['userfile'] ['error'] == UPLOAD_ERR_OK &&
    is_uploaded_file ( $_FILES ['userfile'] ['tmp_name'] )) {

        $csvfile = file_get_contents ( $_FILES ['userfile'] ['tmp_name'] );
    }

    $dict = str_getcsv($csvfile);

And var_dump $dict afterwards, i get

array(4) { [0]=> string(1) "a" [1]=> string(6) "b "aa"" [2]=> 
            string(8) "bb "aaa"" [3]=> string(3) "bbb" }

See index 1, where the first value “b” and the seconde key “aa” are stored in one index.

OpenOffice places no comma behind the values, aka before a new row.
How do I avoid that two strings end up in one index?
Can I somehow tell str_getcsv that when two ” follow each other, it’s also a separator? Or can I add a third column always containing # and say “if it contains #, its a line break? (I tried, and couldn’t manage..)
Or is there even a function, that expects key, value, linebreak in csv?

Whats the correct way to do this? I’m sure people done this so often, but I don’t know how to google it.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T09:09:05+00:00Added an answer on June 5, 2026 at 9:09 am

    How about using fgetcsv() ?
    http://www.php.net/manual/en/function.fgetcsv.php

    It reads line by line, there’s an example in the link.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have generated a csv file in open office but when i open it
I have CSV file and Macro in VBA. I want to open CSV file
I have a comma delimited CSV file being loaded into a String value generated
I have a daily-generated CSV file containing contact data which I want load entries
I have CSV text thats stored in the session array as csv. The lines
I have CSV files that have multiple columns that are sorted. For instance, I
I have .csv file that contain 2 columns delimited with , . file.csv word1,word2
I have some .csv files which I'm using as part of a test bench.
I have 2 csv files: output.csv output1.csv output.csv has a 5 columns of titles.
I have a CSV-like text file that has about 1000 lines. Between each record

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.