Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #13427

Storing strings and numbers properly in CSV files

Newsgroups comp.lang.php
Date 2014-04-22 11:43 -0700
Message-ID <92e0366c-bb9b-48cc-b239-d90f14865c8a@googlegroups.com> (permalink)
Subject Storing strings and numbers properly in CSV files
From sonnichjensen@gmail.com

Show all headers | View raw


Hi

I am saving CSV files from a PHP app, but I face 2 problems:
1. stock numbers are sometimes just numbers, but I'd like to keep them as strings
2. prices are e.g. 5.2 which Excel translates as a date.

Say:

Item;Name;Price;Amount;Total
123;Test;5.2;1;5.2
124;Test2;1.2;2;2.4
Total;;;;=sum(e2:e3)

Just copy this into notepad and save with csv extension and you will see.

I'd like to have 123 and 124 as strings, and eg 5.2 as a float.
Can I format it better than this?

WBR
Sonnich

Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Storing strings and numbers properly in CSV files sonnichjensen@gmail.com - 2014-04-22 11:43 -0700
  Re: Storing strings and numbers properly in CSV files Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-22 15:07 -0400
  Re: Storing strings and numbers properly in CSV files Michael Vilain <vilain@NOspamcop.net> - 2014-04-22 12:53 -0700
  Re: Storing strings and numbers properly in CSV files Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-22 22:29 +0200
    Re: Storing strings and numbers properly in CSV files Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-23 01:27 +0200
  Re: Storing strings and numbers properly in CSV files Richard Yates <richard@yatesguitar.com> - 2014-04-22 16:24 -0700
  Re: Storing strings and numbers properly in CSV files Jim Higgins <ILikeMy@Privacy.invalid> - 2014-04-24 19:21 +0000
  Re: Storing strings and numbers properly in CSV files richard <noreply@example.com> - 2014-05-02 20:48 -0400

csiph-web