PHP header text/csv unwanted line feed character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PHP header text/csv unwanted line feed character
# 1  
Old 05-10-2010
Network PHP header text/csv unwanted line feed character

We have successfully created a comma delimited file, the results are correct from an sql database query. When using the following headers to print the file using print $data, an extra line feed is added and a blank row appears on the top of the data in Excel:

Code:
    header("Expires: 0");
    header("Cache-Control: private");
    header("Pragma: cache");
    header("Content-type: text/csv");    
    header("Content-Disposition: attachment; filename=test.csv");
    print $data;

Note: this character is not in $data itself, but appears after the above headers are sent. Does anyone know why this new line feed character is added and how to remove? Thanks in advance for your help.

Last edited by Scott; 05-10-2010 at 07:08 PM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies

2. UNIX for Beginners Questions & Answers

How to change name of the file with first line of the file which has some unwanted text in it?

I have a log file, which i have divided into 14 files using csplit, the file looks like below test-000000 test-000001 #and so on until 14 now I want all the 14 files generated to be renamed as the some part of test in first line of the file how can i eliminate the unwanted text? sample... (5 Replies)
Discussion started by: Sekhar419
5 Replies

3. Shell Programming and Scripting

How to remove unwanted commas from a .csv file?

how to remove unwanted commas from a .csv file Input file format "Server1","server-PRI-Windows","PRI-VC01","Microsoft Windows Server 2012, (64-bit)","Powered On","1,696.12","server-GEN-SFCHT2-VMS-R013,server-GEN-SFCHT2-VMS-R031,server-GEN-SFCHT2-VMS-R023"... (5 Replies)
Discussion started by: ranjancom2000
5 Replies

4. Shell Programming and Scripting

Insert text line to specific location CSV

In Perl. ***edited question below*** Hey all, I am teaching myself some simple CSV file manipulation and have become a little stuck. Say I have the following layout in the CSV file: age,name,locationIs it possible to INSERT data into the CSV into the correct age order. For example, if I had... (1 Reply)
Discussion started by: whyte_rhyno
1 Replies

5. Shell Programming and Scripting

new line after n'th character in text file

Gurus, I have a text file having only one row having following data. 640.0800 -999.25 -999.25 -999.25 -999.25 -999.25 -999.25 -999.25 -999.25 640.2324 -999.25 -999.25 -999.25 -999.25 -999.25 -999.25 -999.25 -999.25 640.3848 ... (5 Replies)
Discussion started by: Amit.saini333
5 Replies

6. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

7. Shell Programming and Scripting

Remove line feed from csv file column

Hi All, i have a csv file . In the 7th column i have data that has line feed in it. Requirement is to remove the line feed from the 7th column whenever it appears There are 11 columns in the file C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11 The value in C7 contains line feed ( Alt + Enter ),... (2 Replies)
Discussion started by: r_t_1601
2 Replies

8. Shell Programming and Scripting

Remove line feed from csv file column

Hi All, My requirement is to remove line (3 Replies)
Discussion started by: r_t_1601
3 Replies

9. Shell Programming and Scripting

unwanted control character in the input

Hi Shell Scripting Experts, I have a shell script running daily on a remote machine through ssh. To avoid the trouble of restarting the script when ssh disconnects, I use screen (a unix tool) and run the script within a screen session. What this script does is to ask the user to input y or n... (2 Replies)
Discussion started by: jeff_cen
2 Replies

10. Shell Programming and Scripting

replace last form feed with line feed

Hi I have a file with lots of line feeds and form feeds (page break). Need to replace last occurrence of form feed (created by - echo "\f" ) in the file with line feed. Please advise how can i achieve this. TIA Prvn (5 Replies)
Discussion started by: prvnrk
5 Replies
Login or Register to Ask a Question
OpenGuides::Feed(3pm)					User Contributed Perl Documentation				     OpenGuides::Feed(3pm)

       set_feed_name_and_url_params Overrides the default feed name and default feed http equivalent url. Useful on custom feeds, where the
       defaults are incorrect.
	      $feed->set_feed_name_and_url("Search Results", "search=pub");
	      $feed->build_mini_feed_for_nodes("rss", @search_results);

       make_feed
	   Produce one of the standard feeds, in the requested format.

	   my $feed_contents = feeds->make_feed(
					   feed_type => 'rss',
					   feed_listing => 'recent_changes'
			       );

	   Passes additional arguments through to the underlying Wiki::Toolkit::Feed

       build_feed_for_nodes
	   For the given feed type, build a feed from the supplied list of nodes.  Will figure out the feed timestamp from the newest node, and
	   output a
	    last modified header based on this.

	   my @nodes = $wiki->fetch_me_nodes_I_like(); my $feed_contents = $feed->build_feed_for_nodes("rss", @nodes);

       build_mini_feed_for_nodes
	   For the given feed type, build a mini feed (name and distance) from the
	    supplied list of nodes.  Will figure out the feed timestamp from the newest node, and output a
	    last modified header based on this.

	   my @nodes = $wiki->search_near_here(); my $feed_contents = $feed->build_mini_feed_for_nodes("rss", @nodes);

       render_feed_for_nodes
	   Normally internal method to perform the appropriate building of a feed based on a list of nodes.

       default_content_type
	   For the given feed type, return the default content type for that feed.

	   my $content_type = $feed->default_content_type("rss");

       fetch_maker
	   For the given feed type, identify and return the maker routine for feeds of that type.

	   my $maker = $feed->fetch_maker("rss"); my $feed_contents = maker->node_all_versions(%options);

	   Will always return something of type Wiki::Toolkit::Feed::Listing

NAME
OpenGuides::Feed - generate data feeds for OpenGuides in various formats. DESCRIPTION
Produces RSS 1.0 and Atom 1.0 feeds for OpenGuides. Distributed and installed as part of the OpenGuides project, not intended for independent installation. This documentation is probably only useful to OpenGuides developers. SYNOPSIS
use Wiki::Toolkit; use OpenGuides::Config; use OpenGuides::Feed; my $wiki = Wiki::Toolkit->new( ... ); my $config = OpenGuides::Config->new( file => "wiki.conf" ); my $feed = OpenGuides::Feed->new( wiki => $wiki, config => $config, og_version => '1.0', ); # Ten most recent changes in RSS format. my %args = ( items => 10, feed_type => 'rss', also_return_timestamp => 1 ); my ($feed_output,$feed_timestamp) = $feed->make_feed( %args ); print "Content-Type: application/rdf+xml "; print "Last-Modified: " . $feed_timestamp . " "; print $feed_output; METHODS
new my $feed = OpenGuides::Feed->new( wiki => $wiki, config => $config, og_version => '1.0', ); "wiki" must be a Wiki::Toolkit object and "config" must be an OpenGuides::Config object. Both of these arguments are mandatory. "og_version" is an optional argument specifying the version of OpenGuides for inclusion in the feed. rss_maker Returns a raw Wiki::Toolkit::Feed::RSS object created with the values you invoked this module with. atom_maker Returns a raw Wiki::Toolkit::Feed::Atom object created with the values you invoked this module with. make_feed # Ten most recent changes in RSS format. my %args = ( items => 10, feed_type => 'rss', also_return_timestamp => 1 ); my ($feed_output,$feed_timestamp) = $rdf_writer->make_feed( %args ); print "Content-Type: application/rdf+xml "; print "Last-Modified: " . $feed_timestamp . " "; print $feed_output; print $rdf_writer->make_feed( %args ); # All the changes made by bob in the past week, ignoring minor edits, in Atom. $args{days} = 7; $args{ignore_minor_edits = 1; $args{filter_on_metadata} => { username => "bob" }; $args{also_return_timestamp} => 1; my ($feed_output,$feed_timestamp) = $rdf_writer->make_feed( %args ); print "Content-Type: application/atom+xml "; print "Last-Modified: " . $feed_timestamp . " "; print $feed_output; feed_timestamp Instead of calling this, you should instead pass in the 'also_return_timestamp' option. You will then get back the feed timestamp, along with the feed output. This method will be removed in future, and currently will only return meaningful values if your arguments relate to recent changes. print "Last-Modified: " . $feed->feed_timestamp( %args ) . " "; Returns the timestamp of something in POSIX::strftime style ("Tue, 29 Feb 2000 12:34:56 GMT"). Takes the same arguments as make_recentchanges_rss(). You will most likely need this to print a Last-Modified HTTP header so user-agents can determine whether they need to reload the feed or not. SEE ALSO
o Wiki::Toolkit, Wiki::Toolkit::Feed::RSS and Wiki::Toolkit::Feed::Atom o <http://openguides.org/> AUTHOR
The OpenGuides Project (openguides-dev@lists.openguides.org) COPYRIGHT
Copyright (C) 2003-2009 The OpenGuides Project. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. CREDITS
Written by Earle Martin, based on the original OpenGuides::RDF by Kake Pugh. perl v5.14.2 2013-01-11 OpenGuides::Feed(3pm)