LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-06-2010, 12:36 PM   #1
rcvengr2
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
Open Office cell width for .csv files


Hi,

I have written my own matlab script to output a cell array to csv format, but I am having problems when I try to view the file in openoffice. In my script, if the length of the string in the cell is longer than 30 characters long I put a linefeed \n into the fprintf. This all works great and the linefeed works in Open Office, however the width of the columns are still set to the width of the entire length of the string. For example, in my cell I will have several lines 30 chars long, say four lines or 120 chars, and the width of the cell that it is contained in matches the width of about 120 chars long rather than 30. This is a problem because it shows the text all left aligned in the cell, which looks great, but there are pages of white space to the right and the next column is off the screen. This seems obviously inconvenient.

If the string is longer than 30 chars I output it in the following way:

" First 30 characters of the string
the rest of the string
and so on"

I feel like there should be a simple solution to this but I can't find it. Is this a problem with Open Office or my understanding of csv? Would excel have the same problem? How can I fix this?

Thanks,
Bob
 
Old 03-06-2010, 09:11 PM   #2
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
Since the script is your own, you should consider removing the newline if the length is > 30.

Excel would have the same problem.

Alternatively, you can concatenate the trimmed contents of all the fields thus:

If the data is in column A1 (row 2 in this case), the formula

Code:
=CONCATENATE(MID(A1;1;3);MID(A1;31;3);MID(A1;61;3);MID(A1;91;3))
should do.

If needed, you can further modify the formula to check the length of the string in A1 using a series of nested immediate ifs.

Eg:If(len(a1>90);CONCATENATE(MID(A1;1;3);MID(A1;31;3);MID(A1;61;3);MID(A1;91;3));if(len(a1>6)..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing two csv files and write different record in third CSV file irfanb146 Linux - Newbie 3 06-30-2008 09:15 PM
How do I open appleworks files (.cwk) in open office? mkpovak Linux - Desktop 1 08-08-2006 04:03 AM
how to open files from a network server from open office or any apps reycapoy Linux - Software 4 01-26-2006 07:00 PM
Open Office does not open large files linuxfond Linux - Newbie 8 09-26-2004 03:46 AM
Can Open Office open WordPerfect files hemenm Linux - Software 2 03-10-2004 05:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration