You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openoffice.apache.org by Stuart Murray <S....@hart-builders.co.uk> on 2015/01/20 12:49:49 UTC

CSV Files

When I save information as a CSV file it brings up the text import window. I click on ok and then it always opens the file. Is there a way of preventing the file from opening when I click on ok? I do this several times a day every day so each file saved needs to be closed after it is saved. It's not the end of the world but it would save a little time each day and the make the process sleeker for the dozen or so files I am saving all at the same time each day.

Many thanks

Stuart

________________________________
Hart Builders (Edinburgh) Limited, (Registered No SC30263) having its registered office at Macmerry Industrial Estate, East Lothian, EH33 1ET ("the Company").
This message is for the intended recipient only. It may contain confidential or proprietary information. If you receive this message in error, please inform the Company and then immediately delete the message and destroy all copies. You must not use or disclose any part of this message if you are not the intended recipient. Any views expressed in this message are those of the individual sender and do not necessarily represent those of the Company.
We take responsible precautions to ensure our e-mails are virus free. However, we cannot accept responsibility for any virus transmitted and recommend that you perform your own virus checking procedure.
The policy of the company is not to conclude contracts by e-mail. All contracts must be in writing.

Re: CSV Files

Posted by James Knott <ja...@rogers.com>.
On 01/20/2015 04:22 PM, James Plante wrote:
> Just to be a pedantic nit-picker, "csv" stands for "character separated values," not "comma separated values." You choose which character. 

That's the first time I've heard of "character separated values".  I've
only heard of comma separated values, along with tab and space
separated.  I am aware that it's possible to use just about any
character that's not part of the expected data.

https://en.wikipedia.org/wiki/Comma-separated_values
https://en.wikipedia.org/wiki/Delimiter-separated_values
http://acronyms.thefreedictionary.com/Character+Separated+Values
https://tools.ietf.org/html/rfc4180

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-help@openoffice.apache.org


Re: CSV Files

Posted by Jim <ji...@austin.rr.com>.
And if you look at RFC 4180 it refers to

[Abstract
This RFC documents the format used for Comma-Separated Values (CSV)
files and registers the associated MIME type "text/csv".]

On 1/20/2015 3:41 PM, Johnny Rosenberg wrote:
> 2015-01-20 22:22 GMT+01:00 James Plante <ji...@me.com>:
>
>> Just to be a pedantic nit-picker, "csv" stands for "character separated
>> values," not "comma separated values." You choose which character.
>>
> Okay, sorry. I read ”comma separated values” at Wikipedia a while ago, but
> now when I look there again, they also mention ”character separated
> values”. Not that Wikipedia is the world center of all truth, but in many
> cases it's okay to look there anyway…
>
> And I don't have anything against ”pedantic nit-pickers”, I'm a little bit
> of one myself (which of course doesn't mean that I can't be wrong in some
> cases…). I love to learn things, so please continue to be a pedantic
> nit-picker. I think that's appromimately the same as what we in my country
> call a ”besserwisser”, even though it's not the language we speak here. We
> borrowed that one from the Germans… And sometimes when we want to be funny,
> we pronounce it slightly wrong: ”Messerschmitt”…
>
> Kind regards
>
> Johnny Rosenberg
> ジョニー・ローゼンバーグ
>
>
>
>> Hence, the "9" in your arguments to tell it to separate with tabs. You can
>> choose commas, semicolons, or just about any other character.
>>
>> Jim
>>
>>> On Jan 20, 2015, at 2:00 PM, Johnny Rosenberg <gu...@gmail.com>
>> wrote:
>>> 2015-01-20 12:49 GMT+01:00 Stuart Murray <S....@hart-builders.co.uk>:
>>>
>>>> When I save information as a CSV file it brings up the text import
>> window.
>>>> I click on ok and then it always opens the file. Is there a way of
>>>> preventing the file from opening when I click on ok? I do this several
>>>> times a day every day so each file saved needs to be closed after it is
>>>> saved. It's not the end of the world but it would save a little time
>> each
>>>> day and the make the process sleeker for the dozen or so files I am
>> saving
>>>> all at the same time each day.
>>>>
>>>> Many thanks
>>>>
>>>> Stuart
>>>>
>>>>
>>> I'm afraid I can't answer your question, but I still have something to
>> say,
>>> I think.
>>>
>>> I had a couple of spreadsheets that I needed to convert to csv (or rather
>>> tsv – Tab Separated Values, but I still used the .csv suffix) and copy it
>>> to my Android phone, so I could view it there with a simple csv app…
>>>
>>> I used a macro for it and I ran the macro by pushing a button that I
>> added
>>> to the first row of the spreadsheet. That row is always visible, since I
>>> use the Freeze feature, otherwise I could run the macro from the
>> keyboard,
>>> add a menu item or something.
>>>
>>> Anyway, I only needed this for one or two particular document, so some
>>> things in my macro are hard coded. I just wanted to get the job done, so
>> to
>>> speak…
>>>
>>> Here it is. If you want to use it, you need to edit at least the hard
>> coded
>>> path (which is faked in this version anyway)…
>>> I removed the part where it moves the csv to the phone, since that part
>> is
>>> done by a Bash script anyway, called from the macro.
>>>
>>> Sub SaveAsCsv
>>> ' Place the cursor at the first unused row.
>>> Call SelectRow
>>>
>>> ' Then, save the spreadsheet.
>>> ThisComponent.store()
>>>
>>> ' Now, save the active sheet as CSV.
>>> Dim PropVal(1) as New com.sun.star.beans.PropertyValue
>>> PropVal(0).Name="FilterName"
>>> PropVal(0).Value="Text - txt - csv (StarCalc)"
>>> PropVal(1).Name="FilterOptions"
>>> REM You need to edit the line below if you prefer saving as csv rather
>> than
>>> tsv.
>>> REM I don't remember which number means what, but I remember that I
>>> REM ”Googled it” to determine the number that I actually used. A wild
>> guess
>>> REM would be that the 9 means TAB (since that is its ASCII-code), but I'm
>>> REM sure some ”Googling” will get the right numbers for you.
>>> PropVal(1).Value ="9,34,0,1,1"
>>>
>>> Dim FileURL As String, FilePath As String
>>> REM The next line needs to be edited. I'm not sure why I hard coded the
>>> path,
>>> REM but I think I remember that I just couldn't find another way at the
>>> time being.
>>> REM I still would like to know, so if anyone… There should be a simple
>> way
>>> to
>>> REM find out the path to the current file, shouldn't it? I think there
>> were
>>> some
>>> REM discussions about this in this mailing list, but I don't remember if
>>> anyone
>>> REM finally figured it out…
>>> FilePath="/some/path/to/this/file/"
>>> FilePath=FilePath & ThisComponent.getTitle()
>>> FileUrl=ConvertToUrl(FilePath)
>>> FileUrl=Left(FileUrl,Len(FileUrl)-3) & "csv"
>>> ThisComponent.StoreToUrl(FileUrl, PropVal())
>>> End Sub
>>>
>>> Sub SelectRow
>>> Dim Row As Integer, Sheet As Object
>>> Sheet=ThisComponent.Sheets.getByName("Tider")
>>> Row=Sheet.getCellByPosition(0,0).getValue()
>>> SelectFirstEmptyRow(Sheet,0,Row)
>>> End Sub
>>>
>>> Sub SelectFirstEmptyRow(Sheet As Object, Column As Integer,Row As
>> Integer)
>>> Dim Cell As Object
>>> Dim Ranges As Object
>>>
>>> Cell=Sheet.GetCellByPosition(Column,Row)
>>>
>>> SelectCell(Sheet,Column,Row)
>>> End Sub
>>>
>>> Function SelectCell(Sheet As Object, Column As Integer,Row As Integer)
>>> ' Select and highlight the cell
>>>
>> ThisComponent.CurrentController.Select(Sheet.getCellByPosition(Column,Row))
>>> SelectEmptyRange
>>> End Function
>>>
>>> Sub SelectEmptyRange
>>> Dim EmptyRange
>>>
>>>
>> EmptyRange=ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
>>> ThisComponent.CurrentController.Select(EmptyRange)
>>> End Sub
>>>
>>>
>>> Read the REM lines above for more information…
>>>
>>>
>>>
>>> Kind regards
>>>
>>> Johnny Rosenberg
>>> ジョニー・ローゼンバーグ
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@openoffice.apache.org
>> For additional commands, e-mail: users-help@openoffice.apache.org
>>
>>

-- 
"When you do things right, people won't be sure you've done anything at all." Futurama, Godfellas (2002)


Re: CSV Files

Posted by Johnny Rosenberg <gu...@gmail.com>.
2015-01-20 22:22 GMT+01:00 James Plante <ji...@me.com>:

> Just to be a pedantic nit-picker, "csv" stands for "character separated
> values," not "comma separated values." You choose which character.
>

Okay, sorry. I read ”comma separated values” at Wikipedia a while ago, but
now when I look there again, they also mention ”character separated
values”. Not that Wikipedia is the world center of all truth, but in many
cases it's okay to look there anyway…

And I don't have anything against ”pedantic nit-pickers”, I'm a little bit
of one myself (which of course doesn't mean that I can't be wrong in some
cases…). I love to learn things, so please continue to be a pedantic
nit-picker. I think that's appromimately the same as what we in my country
call a ”besserwisser”, even though it's not the language we speak here. We
borrowed that one from the Germans… And sometimes when we want to be funny,
we pronounce it slightly wrong: ”Messerschmitt”…

Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ



>
> Hence, the "9" in your arguments to tell it to separate with tabs. You can
> choose commas, semicolons, or just about any other character.
>
> Jim
>
> > On Jan 20, 2015, at 2:00 PM, Johnny Rosenberg <gu...@gmail.com>
> wrote:
> >
> > 2015-01-20 12:49 GMT+01:00 Stuart Murray <S....@hart-builders.co.uk>:
> >
> >> When I save information as a CSV file it brings up the text import
> window.
> >> I click on ok and then it always opens the file. Is there a way of
> >> preventing the file from opening when I click on ok? I do this several
> >> times a day every day so each file saved needs to be closed after it is
> >> saved. It's not the end of the world but it would save a little time
> each
> >> day and the make the process sleeker for the dozen or so files I am
> saving
> >> all at the same time each day.
> >>
> >> Many thanks
> >>
> >> Stuart
> >>
> >>
> > I'm afraid I can't answer your question, but I still have something to
> say,
> > I think.
> >
> > I had a couple of spreadsheets that I needed to convert to csv (or rather
> > tsv – Tab Separated Values, but I still used the .csv suffix) and copy it
> > to my Android phone, so I could view it there with a simple csv app…
> >
> > I used a macro for it and I ran the macro by pushing a button that I
> added
> > to the first row of the spreadsheet. That row is always visible, since I
> > use the Freeze feature, otherwise I could run the macro from the
> keyboard,
> > add a menu item or something.
> >
> > Anyway, I only needed this for one or two particular document, so some
> > things in my macro are hard coded. I just wanted to get the job done, so
> to
> > speak…
> >
> > Here it is. If you want to use it, you need to edit at least the hard
> coded
> > path (which is faked in this version anyway)…
> > I removed the part where it moves the csv to the phone, since that part
> is
> > done by a Bash script anyway, called from the macro.
> >
> > Sub SaveAsCsv
> > ' Place the cursor at the first unused row.
> > Call SelectRow
> >
> > ' Then, save the spreadsheet.
> > ThisComponent.store()
> >
> > ' Now, save the active sheet as CSV.
> > Dim PropVal(1) as New com.sun.star.beans.PropertyValue
> > PropVal(0).Name="FilterName"
> > PropVal(0).Value="Text - txt - csv (StarCalc)"
> > PropVal(1).Name="FilterOptions"
> > REM You need to edit the line below if you prefer saving as csv rather
> than
> > tsv.
> > REM I don't remember which number means what, but I remember that I
> > REM ”Googled it” to determine the number that I actually used. A wild
> guess
> > REM would be that the 9 means TAB (since that is its ASCII-code), but I'm
> > REM sure some ”Googling” will get the right numbers for you.
> > PropVal(1).Value ="9,34,0,1,1"
> >
> > Dim FileURL As String, FilePath As String
> > REM The next line needs to be edited. I'm not sure why I hard coded the
> > path,
> > REM but I think I remember that I just couldn't find another way at the
> > time being.
> > REM I still would like to know, so if anyone… There should be a simple
> way
> > to
> > REM find out the path to the current file, shouldn't it? I think there
> were
> > some
> > REM discussions about this in this mailing list, but I don't remember if
> > anyone
> > REM finally figured it out…
> > FilePath="/some/path/to/this/file/"
> > FilePath=FilePath & ThisComponent.getTitle()
> > FileUrl=ConvertToUrl(FilePath)
> > FileUrl=Left(FileUrl,Len(FileUrl)-3) & "csv"
> > ThisComponent.StoreToUrl(FileUrl, PropVal())
> > End Sub
> >
> > Sub SelectRow
> > Dim Row As Integer, Sheet As Object
> > Sheet=ThisComponent.Sheets.getByName("Tider")
> > Row=Sheet.getCellByPosition(0,0).getValue()
> > SelectFirstEmptyRow(Sheet,0,Row)
> > End Sub
> >
> > Sub SelectFirstEmptyRow(Sheet As Object, Column As Integer,Row As
> Integer)
> > Dim Cell As Object
> > Dim Ranges As Object
> >
> > Cell=Sheet.GetCellByPosition(Column,Row)
> >
> > SelectCell(Sheet,Column,Row)
> > End Sub
> >
> > Function SelectCell(Sheet As Object, Column As Integer,Row As Integer)
> > ' Select and highlight the cell
> >
> ThisComponent.CurrentController.Select(Sheet.getCellByPosition(Column,Row))
> > SelectEmptyRange
> > End Function
> >
> > Sub SelectEmptyRange
> > Dim EmptyRange
> >
> >
> EmptyRange=ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
> > ThisComponent.CurrentController.Select(EmptyRange)
> > End Sub
> >
> >
> > Read the REM lines above for more information…
> >
> >
> >
> > Kind regards
> >
> > Johnny Rosenberg
> > ジョニー・ローゼンバーグ
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@openoffice.apache.org
> For additional commands, e-mail: users-help@openoffice.apache.org
>
>

Re: CSV Files

Posted by Lee Fisher <l....@gmail.com>.
> When I save information as a CSV file it brings up the text import window.
> I click on ok and then it always opens the file. Is there a way of
> preventing the file from opening when I click on ok? I do this several
> times a day every day so each file saved needs to be closed after it is
> saved. It's not the end of the world but it would save a little time each
> day and the make the process sleeker for the dozen or so files I am saving
> all at the same time each day.

There are a few command line tools to convert CSVs to ODFs, so you can
avoid the GUI import phase and skip to a GUI open phase. Here are two of
them, there are a few others in non-Python languages, but I can't find
them right now:

http://sourceforge.net/p/csv2odf/wiki/Main_Page/
https://pypi.python.org/pypi/odfpy

Also, try 'soffice --help', it may have some option (...and if not, it
should).

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-help@openoffice.apache.org


Re: CSV Files

Posted by James Plante <ji...@me.com>.
Just to be a pedantic nit-picker, "csv" stands for "character separated values," not "comma separated values." You choose which character. 

Hence, the "9" in your arguments to tell it to separate with tabs. You can choose commas, semicolons, or just about any other character.

Jim

> On Jan 20, 2015, at 2:00 PM, Johnny Rosenberg <gu...@gmail.com> wrote:
> 
> 2015-01-20 12:49 GMT+01:00 Stuart Murray <S....@hart-builders.co.uk>:
> 
>> When I save information as a CSV file it brings up the text import window.
>> I click on ok and then it always opens the file. Is there a way of
>> preventing the file from opening when I click on ok? I do this several
>> times a day every day so each file saved needs to be closed after it is
>> saved. It's not the end of the world but it would save a little time each
>> day and the make the process sleeker for the dozen or so files I am saving
>> all at the same time each day.
>> 
>> Many thanks
>> 
>> Stuart
>> 
>> 
> I'm afraid I can't answer your question, but I still have something to say,
> I think.
> 
> I had a couple of spreadsheets that I needed to convert to csv (or rather
> tsv – Tab Separated Values, but I still used the .csv suffix) and copy it
> to my Android phone, so I could view it there with a simple csv app…
> 
> I used a macro for it and I ran the macro by pushing a button that I added
> to the first row of the spreadsheet. That row is always visible, since I
> use the Freeze feature, otherwise I could run the macro from the keyboard,
> add a menu item or something.
> 
> Anyway, I only needed this for one or two particular document, so some
> things in my macro are hard coded. I just wanted to get the job done, so to
> speak…
> 
> Here it is. If you want to use it, you need to edit at least the hard coded
> path (which is faked in this version anyway)…
> I removed the part where it moves the csv to the phone, since that part is
> done by a Bash script anyway, called from the macro.
> 
> Sub SaveAsCsv
> ' Place the cursor at the first unused row.
> Call SelectRow
> 
> ' Then, save the spreadsheet.
> ThisComponent.store()
> 
> ' Now, save the active sheet as CSV.
> Dim PropVal(1) as New com.sun.star.beans.PropertyValue
> PropVal(0).Name="FilterName"
> PropVal(0).Value="Text - txt - csv (StarCalc)"
> PropVal(1).Name="FilterOptions"
> REM You need to edit the line below if you prefer saving as csv rather than
> tsv.
> REM I don't remember which number means what, but I remember that I
> REM ”Googled it” to determine the number that I actually used. A wild guess
> REM would be that the 9 means TAB (since that is its ASCII-code), but I'm
> REM sure some ”Googling” will get the right numbers for you.
> PropVal(1).Value ="9,34,0,1,1"
> 
> Dim FileURL As String, FilePath As String
> REM The next line needs to be edited. I'm not sure why I hard coded the
> path,
> REM but I think I remember that I just couldn't find another way at the
> time being.
> REM I still would like to know, so if anyone… There should be a simple way
> to
> REM find out the path to the current file, shouldn't it? I think there were
> some
> REM discussions about this in this mailing list, but I don't remember if
> anyone
> REM finally figured it out…
> FilePath="/some/path/to/this/file/"
> FilePath=FilePath & ThisComponent.getTitle()
> FileUrl=ConvertToUrl(FilePath)
> FileUrl=Left(FileUrl,Len(FileUrl)-3) & "csv"
> ThisComponent.StoreToUrl(FileUrl, PropVal())
> End Sub
> 
> Sub SelectRow
> Dim Row As Integer, Sheet As Object
> Sheet=ThisComponent.Sheets.getByName("Tider")
> Row=Sheet.getCellByPosition(0,0).getValue()
> SelectFirstEmptyRow(Sheet,0,Row)
> End Sub
> 
> Sub SelectFirstEmptyRow(Sheet As Object, Column As Integer,Row As Integer)
> Dim Cell As Object
> Dim Ranges As Object
> 
> Cell=Sheet.GetCellByPosition(Column,Row)
> 
> SelectCell(Sheet,Column,Row)
> End Sub
> 
> Function SelectCell(Sheet As Object, Column As Integer,Row As Integer)
> ' Select and highlight the cell
> ThisComponent.CurrentController.Select(Sheet.getCellByPosition(Column,Row))
> SelectEmptyRange
> End Function
> 
> Sub SelectEmptyRange
> Dim EmptyRange
> 
> EmptyRange=ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
> ThisComponent.CurrentController.Select(EmptyRange)
> End Sub
> 
> 
> Read the REM lines above for more information…
> 
> 
> 
> Kind regards
> 
> Johnny Rosenberg
> ジョニー・ローゼンバーグ


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-help@openoffice.apache.org


Re: CSV Files

Posted by Johnny Rosenberg <gu...@gmail.com>.
2015-01-20 12:49 GMT+01:00 Stuart Murray <S....@hart-builders.co.uk>:

> When I save information as a CSV file it brings up the text import window.
> I click on ok and then it always opens the file. Is there a way of
> preventing the file from opening when I click on ok? I do this several
> times a day every day so each file saved needs to be closed after it is
> saved. It's not the end of the world but it would save a little time each
> day and the make the process sleeker for the dozen or so files I am saving
> all at the same time each day.
>
> Many thanks
>
> Stuart
>
>
I'm afraid I can't answer your question, but I still have something to say,
I think.

I had a couple of spreadsheets that I needed to convert to csv (or rather
tsv – Tab Separated Values, but I still used the .csv suffix) and copy it
to my Android phone, so I could view it there with a simple csv app…

I used a macro for it and I ran the macro by pushing a button that I added
to the first row of the spreadsheet. That row is always visible, since I
use the Freeze feature, otherwise I could run the macro from the keyboard,
add a menu item or something.

Anyway, I only needed this for one or two particular document, so some
things in my macro are hard coded. I just wanted to get the job done, so to
speak…

Here it is. If you want to use it, you need to edit at least the hard coded
path (which is faked in this version anyway)…
I removed the part where it moves the csv to the phone, since that part is
done by a Bash script anyway, called from the macro.

Sub SaveAsCsv
' Place the cursor at the first unused row.
Call SelectRow

' Then, save the spreadsheet.
ThisComponent.store()

' Now, save the active sheet as CSV.
Dim PropVal(1) as New com.sun.star.beans.PropertyValue
PropVal(0).Name="FilterName"
PropVal(0).Value="Text - txt - csv (StarCalc)"
PropVal(1).Name="FilterOptions"
REM You need to edit the line below if you prefer saving as csv rather than
tsv.
REM I don't remember which number means what, but I remember that I
REM ”Googled it” to determine the number that I actually used. A wild guess
REM would be that the 9 means TAB (since that is its ASCII-code), but I'm
REM sure some ”Googling” will get the right numbers for you.
PropVal(1).Value ="9,34,0,1,1"

Dim FileURL As String, FilePath As String
REM The next line needs to be edited. I'm not sure why I hard coded the
path,
REM but I think I remember that I just couldn't find another way at the
time being.
REM I still would like to know, so if anyone… There should be a simple way
to
REM find out the path to the current file, shouldn't it? I think there were
some
REM discussions about this in this mailing list, but I don't remember if
anyone
REM finally figured it out…
FilePath="/some/path/to/this/file/"
FilePath=FilePath & ThisComponent.getTitle()
FileUrl=ConvertToUrl(FilePath)
FileUrl=Left(FileUrl,Len(FileUrl)-3) & "csv"
ThisComponent.StoreToUrl(FileUrl, PropVal())
End Sub

Sub SelectRow
Dim Row As Integer, Sheet As Object
 Sheet=ThisComponent.Sheets.getByName("Tider")
Row=Sheet.getCellByPosition(0,0).getValue()
SelectFirstEmptyRow(Sheet,0,Row)
End Sub

Sub SelectFirstEmptyRow(Sheet As Object, Column As Integer,Row As Integer)
Dim Cell As Object
Dim Ranges As Object

Cell=Sheet.GetCellByPosition(Column,Row)

SelectCell(Sheet,Column,Row)
End Sub

Function SelectCell(Sheet As Object, Column As Integer,Row As Integer)
' Select and highlight the cell
ThisComponent.CurrentController.Select(Sheet.getCellByPosition(Column,Row))
SelectEmptyRange
End Function

Sub SelectEmptyRange
Dim EmptyRange

EmptyRange=ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
ThisComponent.CurrentController.Select(EmptyRange)
End Sub


Read the REM lines above for more information…



Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ