Re: Autosizing Cells

2005-12-24 Thread Brian Bernard

Thanks. That's all I needed to know. 


Brian Bernard
Senior, Direct Advanced Response Team
Premier Support - Enterprise
Research In Motion Limited 
Direct Dial: 1-519-888-7465 x5654
Email: [EMAIL PROTECTED]

/* Sent using my BlackBerry 8700 */


- Original Message -
From: Xavier Noria
To: Perl Beginners
Sent: Sat Dec 24 13:16:23 2005
Subject: Re: Autosizing Cells

On Dec 24, 2005, at 18:59, Brian Bernard wrote:

> What I was intending to ask is whether a CSV can be created with  
> the logic to open with auto-sized columns, when opened in a  
> application capable of displaying the data in columns. For example,  
> if you view an html file in a text editor, you will see the html  
> formatting but not in the way that it was intended to be viewed,  
> since a text editor does not display html. Is there a way to add  
> extra logic to a CSV such that when it is opened in Excel, the data  
> that is delimited is injected into columns that are auto-sized? I  
> am aware of better ways of doing this, I just want to know if what  
> I am asking is possible.

Nope, CSV is plain text plus some conventions for delimiting records  
and fields (conventions have variations). No room for formatting  
metadata like that. See http://en.wikipedia.org/wiki/Comma- 
separated_values.

-- fxn



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>





-
This transmission (including any attachments) may contain confidential 
information, privileged material (including material protected by the 
solicitor-client or other applicable privileges), or constitute non-public 
information. Any use of this information by anyone other than the intended 
recipient is prohibited. If you have received this transmission in error, 
please immediately reply to the sender and delete this information from your 
system. Use, dissemination, distribution, or reproduction of this transmission 
by unintended recipients is not authorized and may be unlawful.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Autosizing Cells

2005-12-24 Thread Xavier Noria

On Dec 24, 2005, at 18:59, Brian Bernard wrote:

What I was intending to ask is whether a CSV can be created with  
the logic to open with auto-sized columns, when opened in a  
application capable of displaying the data in columns. For example,  
if you view an html file in a text editor, you will see the html  
formatting but not in the way that it was intended to be viewed,  
since a text editor does not display html. Is there a way to add  
extra logic to a CSV such that when it is opened in Excel, the data  
that is delimited is injected into columns that are auto-sized? I  
am aware of better ways of doing this, I just want to know if what  
I am asking is possible.


Nope, CSV is plain text plus some conventions for delimiting records  
and fields (conventions have variations). No room for formatting  
metadata like that. See http://en.wikipedia.org/wiki/Comma- 
separated_values.


-- fxn



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Autosizing Cells

2005-12-24 Thread Brian Bernard

Hello Chris,

Yes, I understand what a CSV file is. My question was a simple one, I just 
wasn't being clear enough, I guess. 

What I was intending to ask is whether a CSV can be created with the logic to 
open with auto-sized columns, when opened in a application capable of 
displaying the data in columns. For example, if you view an html file in a text 
editor, you will see the html formatting but not in the way that it was 
intended to be viewed, since a text editor does not display html. Is there a 
way to add extra logic to a CSV such that when it is opened in Excel, the data 
that is delimited is injected into columns that are auto-sized? I am aware of 
better ways of doing this, I just want to know if what I am asking is possible. 

Thanks. 


Brian Bernard
Senior, Direct Advanced Response Team
Premier Support - Enterprise
Research In Motion Limited 
Direct Dial: 1-519-888-7465 x5654
Email: [EMAIL PROTECTED]

/* Sent using my BlackBerry 8700 */


- Original Message -
From: Chris Devers
To: Brian Bernard
Cc: beginners@perl.org
Sent: Sat Dec 24 11:45:24 2005
Subject: Re: Autosizing Cells

On Sat, 24 Dec 2005, Brian Bernard wrote:

> Is there any way to auto-size cells when you are generating a CSV file 
> using Perl (without using any additional modules)?

Do you understand what CSV is? It's just a plain text representation of 
tabular data, with rows separated by newlines and columns separated by 
commas. For example:

Album,Artist,Year
Abbey Road,The Beatles,1969
Elephant,The White Stripes,2003

That's it. Save those three lines as, say, albums.csv, and it would be a 
perfectly good CSV file exactly as is. 

CSV is the quintessential quick & dirty file format. It has no concept
of formatting the data in any way -- field size, colors, fonts, etc -- 
because it's just plain ASCII text with some arbitrary characters thrown 
in as impromptu field delimiters. It's not even very good at this, 
because if the text you want to store happens to have that delimiter 
character, then the columns in that row go out of whack. 

Album,Artist,Year
The Dropper,Medeski, Martin, & Wood,1996

Oops. Too many columns. Now you have to start making decisions. You have 
two or three choices: come up with some kind of escape character so that 
the delimiter only counts when it hasn't been escaped --

Album,Artist,Year
The Dropper,Medeski\,\ Martin\,\ \&\ Wood,1996

-- or use a different character to separate fields in the text --

Album|Artist|Year
The Dropper|Medeski, Martin, & Wood|1996

-- or perhaps wrap columns in additional quotation characters --

"Album","Artist","Year"
"The Dropper","Medeski, Martin, & Wood","1996"

-- but either way, you just sacrificed a lot of the simplicity of CSV, 
because now anyone trying to parse the data has to figure out which of 
these arbitrary adaptations to the format you had to make in order to 
keep the columns clean in the data. 


SO. Let's back up a little. You keep asking these questions about how to 
work with CSV, but you're clearly trying to use it in ways that it just 
isn't good at. If you want the things you're asking for -- formatted 
cells, custom column widths, predictable field boundaries, etc -- then 
maybe CSV isn't a suitable task for what you need. 

As was suggested the last time this came up, an Excel spreadsheet file 
is a popular and robust way to do the things you're asking for, but the 
minor tradeoff is that, unless you want to directly work on the Excel 
binary format by hand -- hint, you do not want to do this -- then you 
have to use a CPAN module like Spreadsheet::WriteExcel. This really 
isn't very hard to do, and would make your task much easier. 

Alternatively, you may wish to format your data as XML, which would be 
good for representing the data, but less so for representing the format 
unless you take the additional step of adding XSL or whatever to 
describe how to display the XML data. 

Abbey RoadThe Beatles1969
ElephantThe White Stripes2003
The DropperMedeski, Martin, & 
Wood1996

Or to take most of the format issue out of the equation altogether, you 
could just use an HTML table: the data wouldn't be as well represented 
as it would with XML, but then that's also a problem with CSV, so you're 
no worse off, but now you can use HTML formatting or CSS to decorate the 
data in just about any way you would care to try.


AlbumArtistYear
Abbey RoadThe Beatles1969
ElephantThe White Stripes2003
The DropperMedeski, Martin, & Wood1996


The nice thing about XML or HTML here is that, while the formats are 
complex enough to support a rich library of CPAN modules for generating 
them -- and you're strongly recommended to look at some of these -- the 
formats are still simple enough that you can realistically produce the 
data with straight core Perl and no externa

Re: Autosizing Cells

2005-12-24 Thread Chris Devers
On Sat, 24 Dec 2005, Brian Bernard wrote:

> Is there any way to auto-size cells when you are generating a CSV file 
> using Perl (without using any additional modules)?

Do you understand what CSV is? It's just a plain text representation of 
tabular data, with rows separated by newlines and columns separated by 
commas. For example:

Album,Artist,Year
Abbey Road,The Beatles,1969
Elephant,The White Stripes,2003

That's it. Save those three lines as, say, albums.csv, and it would be a 
perfectly good CSV file exactly as is. 

CSV is the quintessential quick & dirty file format. It has no concept
of formatting the data in any way -- field size, colors, fonts, etc -- 
because it's just plain ASCII text with some arbitrary characters thrown 
in as impromptu field delimiters. It's not even very good at this, 
because if the text you want to store happens to have that delimiter 
character, then the columns in that row go out of whack. 

Album,Artist,Year
The Dropper,Medeski, Martin, & Wood,1996

Oops. Too many columns. Now you have to start making decisions. You have 
two or three choices: come up with some kind of escape character so that 
the delimiter only counts when it hasn't been escaped --

Album,Artist,Year
The Dropper,Medeski\,\ Martin\,\ \&\ Wood,1996

-- or use a different character to separate fields in the text --

Album|Artist|Year
The Dropper|Medeski, Martin, & Wood|1996

-- or perhaps wrap columns in additional quotation characters --

"Album","Artist","Year"
"The Dropper","Medeski, Martin, & Wood","1996"

-- but either way, you just sacrificed a lot of the simplicity of CSV, 
because now anyone trying to parse the data has to figure out which of 
these arbitrary adaptations to the format you had to make in order to 
keep the columns clean in the data. 


SO. Let's back up a little. You keep asking these questions about how to 
work with CSV, but you're clearly trying to use it in ways that it just 
isn't good at. If you want the things you're asking for -- formatted 
cells, custom column widths, predictable field boundaries, etc -- then 
maybe CSV isn't a suitable task for what you need. 

As was suggested the last time this came up, an Excel spreadsheet file 
is a popular and robust way to do the things you're asking for, but the 
minor tradeoff is that, unless you want to directly work on the Excel 
binary format by hand -- hint, you do not want to do this -- then you 
have to use a CPAN module like Spreadsheet::WriteExcel. This really 
isn't very hard to do, and would make your task much easier. 

Alternatively, you may wish to format your data as XML, which would be 
good for representing the data, but less so for representing the format 
unless you take the additional step of adding XSL or whatever to 
describe how to display the XML data. 

Abbey RoadThe Beatles1969
ElephantThe White Stripes2003
The DropperMedeski, Martin, & 
Wood1996

Or to take most of the format issue out of the equation altogether, you 
could just use an HTML table: the data wouldn't be as well represented 
as it would with XML, but then that's also a problem with CSV, so you're 
no worse off, but now you can use HTML formatting or CSS to decorate the 
data in just about any way you would care to try.


AlbumArtistYear
Abbey RoadThe Beatles1969
ElephantThe White Stripes2003
The DropperMedeski, Martin, & Wood1996


The nice thing about XML or HTML here is that, while the formats are 
complex enough to support a rich library of CPAN modules for generating 
them -- and you're strongly recommended to look at some of these -- the 
formats are still simple enough that you can realistically produce the 
data with straight core Perl and no external CPAN dependencies. So if 
that's really a stumbling block for you, this is a way around it.

In any event, it seems like you need to reassess what you're trying to 
do here. The questions you're asking don't make sense at all for working 
with pure CSV data, which implies that you're either trying to do more 
than is feasible with data files you're getting from somewhere else, or 
you're trying to provide data to somewhere else in a format that can't 
do all the things you need it to do. Either way, considering a different 
way to represent your data would probably make your task much simpler.



-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Autosizing Cells

2005-12-24 Thread Brian Bernard

Hello,

Is there any way to auto-size cells when you are generating a CSV file using 
Perl (without using any additional modules)?

Thanks. 

Brian Bernard
Senior, Direct Advanced Response Team
Premier Support - Enterprise
Research In Motion Limited 
Direct Dial: 1-519-888-7465 x5654
Email: [EMAIL PROTECTED]

/* Sent using my BlackBerry 8700 */



-
This transmission (including any attachments) may contain confidential 
information, privileged material (including material protected by the 
solicitor-client or other applicable privileges), or constitute non-public 
information. Any use of this information by anyone other than the intended 
recipient is prohibited. If you have received this transmission in error, 
please immediately reply to the sender and delete this information from your 
system. Use, dissemination, distribution, or reproduction of this transmission 
by unintended recipients is not authorized and may be unlawful.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]