Page 1 of 1 1
Topic Options
#172111 - 2006-12-28 10:49 AM writing to a csv file
shamster Offline
Lurker

Registered: 2006-11-09
Posts: 1
Hi guys, first post so go easy on me

I had a search for the answer but couldn't find it

basically I have a login script which I have inherited, I want it to write an entry into a csv file to update it with some info

what commmand do you need to use?

Top
#172113 - 2006-12-28 11:37 AM Re: writing to a csv file [Re: shamster]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Hi and welcome to the board.

You could use writeline to write to a csv file.

Code:
Break on
;
;Open the file.
$rc = Open (1, "c:\somefile.csv", 5)
;
;Write stuff to the file.
$rc = WriteLine (1, "some data to write to the csv file" + @CRLF)
;
;Close the file.
$rc = Close (1)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#172126 - 2006-12-28 03:09 PM Re: writing to a csv file [Re: shamster]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
The CSV UDF assures a properly formatted CSV record. Send it an array, you get a CSV string. Send it a CSV string, you get an array.

So, if you load your data into an array, it becomes this simple:
Code:
$array = 'data', 'data', 'more data' ...
$RC = RedirectOutput('your_log.csv')
CSV($array) ; csv string is not captured, just written to StdOut
$RC = RedirectOutput('')


Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#172150 - 2006-12-29 01:43 AM Re: writing to a csv file [Re: Glenn Barnas]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
However, you will have to ensure that you send in the correct amount of data. A CSV file is essentially a table where the columns are being separated by commas (enclose strings with quotation marks in case they could contain commas), and each line represents a row.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.052 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org