Importing a csv (tab delimited) to existing non-empty sheet (overwrite)

classic Classic list List threaded Threaded
3 messages Options
Johnny Rosenberg Johnny Rosenberg
Reply | Threaded
Open this post in threaded view
|

Importing a csv (tab delimited) to existing non-empty sheet (overwrite)

Hi!

I have some problems to find information about this. All I found after
hours of searching are few examples that probably work in some situations
but certainly not what I'm looking for,

The problem is that those examples contains a lot of anonymous numbers and
stuff but no explanation what so ever what those numbers mean or where I
can find the details.

Here's the closest thing I came up with so far:
Sub Main
Dim HOME As String
Dim DirName As String
Dim FileName As String
Dim Args(1) As new com.sun.star.beans.PropertyValue

HOME="/home/<MyUserName>"
DirName = HOME & "/Some/Path/"
FileName = ConvertToURL(DirName & "/MyFile.csv")
' Get the latest results.
Shell(HOME & "/bin/ScriptThatCreatesMyFile.sh", True)
Args(0).Name = "FilterName"
Args(0).Value = "Text - txt - csv (StarCalc)"
Args(1).Name = "FilterOptions"
Args(1).Value = "44,34,76,1,,0,False,True,True,False"
StarDesktop.loadComponentFromURL(FileName, "_default", 2, Args())
End Sub

Questions:
Exactly what does ”44,34,76,1,,0,False,True,True,False” mean? Where can I
find information about this? What is True? What is False? Why is something
missing between two commas? Many questions come to my mind…

Problems at the moment:

   1. The code above seems to treat my file as comma separated. I need TAB
   only as separator.
   2. The CSV file is imported to a new window. I want it to overwrite
   existing (old and outdated) information in columns A:D (without messing
   with my conditional and unconditional formatting) on Sheet 0.

After som further experimenting I seem to have solved problem 1. It seems
lik means Chr(44), which is a comma, and Chr(34) os a double quote. The
following line gave me separate columns for every TAB:
Args(1).Value = "9,,76,1,,0,False,True,True,False"
But what does the rest mean? Chr(76)="L", which seems weird, so I guess the
”76” means something else.

I wonder why this kind of information is so hard to find. For easy stuff,
when no manual is needed, you can find tons of information, but when things
are a bit more cryptic, when a manual is really, really needed, you can
search for hours and find nothing, as it seems. Maybe I'm wrong, I actually
hope I am, even if I would look stupid… :P



Kind regards

Johnny Rosenberg

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Andrew Pitonyak Andrew Pitonyak
Reply | Threaded
Open this post in threaded view
|

Re: Importing a csv (tab delimited) to existing non-empty sheet (overwrite)

http://www.pitonyak.org/database/

Look at my random DB ramblings....

I don't remember if I have better coverage they're pretty in my primary macro book

http://www.pitonyak.org/oo.php

But I do explain them, but I cannot check the documents from my phone...

⁣Sent from BlueMail ​

On Nov 20, 2017, 4:47 PM, at 4:47 PM, Johnny Rosenberg <[hidden email]> wrote:

>Hi!
>
>I have some problems to find information about this. All I found after
>hours of searching are few examples that probably work in some
>situations
>but certainly not what I'm looking for,
>
>The problem is that those examples contains a lot of anonymous numbers
>and
>stuff but no explanation what so ever what those numbers mean or where
>I
>can find the details.
>
>Here's the closest thing I came up with so far:
>Sub Main
>Dim HOME As String
>Dim DirName As String
>Dim FileName As String
>Dim Args(1) As new com.sun.star.beans.PropertyValue
>
>HOME="/home/<MyUserName>"
>DirName = HOME & "/Some/Path/"
>FileName = ConvertToURL(DirName & "/MyFile.csv")
>' Get the latest results.
>Shell(HOME & "/bin/ScriptThatCreatesMyFile.sh", True)
>Args(0).Name = "FilterName"
>Args(0).Value = "Text - txt - csv (StarCalc)"
>Args(1).Name = "FilterOptions"
>Args(1).Value = "44,34,76,1,,0,False,True,True,False"
>StarDesktop.loadComponentFromURL(FileName, "_default", 2, Args())
>End Sub
>
>Questions:
>Exactly what does ”44,34,76,1,,0,False,True,True,False” mean? Where can
>I
>find information about this? What is True? What is False? Why is
>something
>missing between two commas? Many questions come to my mind…
>
>Problems at the moment:
>
>1. The code above seems to treat my file as comma separated. I need TAB
>   only as separator.
>   2. The CSV file is imported to a new window. I want it to overwrite
>existing (old and outdated) information in columns A:D (without messing
>   with my conditional and unconditional formatting) on Sheet 0.
>
>After som further experimenting I seem to have solved problem 1. It
>seems
>lik means Chr(44), which is a comma, and Chr(34) os a double quote. The
>following line gave me separate columns for every TAB:
>Args(1).Value = "9,,76,1,,0,False,True,True,False"
>But what does the rest mean? Chr(76)="L", which seems weird, so I guess
>the
>”76” means something else.
>
>I wonder why this kind of information is so hard to find. For easy
>stuff,
>when no manual is needed, you can find tons of information, but when
>things
>are a bit more cryptic, when a manual is really, really needed, you can
>search for hours and find nothing, as it seems. Maybe I'm wrong, I
>actually
>hope I am, even if I would look stupid… :P
>
>
>
>Kind regards
>
>Johnny Rosenberg
>
>--
>To unsubscribe e-mail to: [hidden email]
>Problems?
>https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
>Posting guidelines + more:
>https://wiki.documentfoundation.org/Netiquette
>List archive: https://listarchives.libreoffice.org/global/users/
>All messages sent to this list will be publicly archived and cannot be
>deleted

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Johnny Rosenberg Johnny Rosenberg
Reply | Threaded
Open this post in threaded view
|

Re: Importing a csv (tab delimited) to existing non-empty sheet (overwrite)

2017-11-21 1:06 GMT+01:00 Andrew Pitonyak <[hidden email]>:

> http://www.pitonyak.org/database/
>
> Look at my random DB ramblings....
>
> I don't remember if I have better coverage they're pretty in my primary
> macro book
>
> http://www.pitonyak.org/oo.php
>
> But I do explain them, but I cannot check the documents from my phone...
>

Ok, I'll have a look, thank you for replying!
And thanks to everyone else who also replied, here or to me in private
(probably intended for the list).

I also remembered that I think I've done this before a couple of years ago
(I wonder how I found out how to do it back then…), so I'll also have a
look at old code. I usually never delete anything, so I should find it if
it exists…


Kind regards

Johnny Rosenberg


> Sent from BlueMail <http://www.bluemail.me/r?b=11061>
> On Nov 20, 2017, at 4:47 PM, Johnny Rosenberg <[hidden email]>
> wrote:
>
>> Hi!
>>
>> I have some problems to find information about this. All I found after
>> hours of searching are few examples that probably work in some situations
>> but certainly not what I'm looking for,
>>
>> The problem is that those examples contains a lot of anonymous numbers and
>> stuff but no explanation what so ever what those numbers mean or where I
>> can find the details.
>>
>> Here's the closest thing I came up with so far:
>> Sub Main
>> Dim HOME As String
>> Dim DirName As String
>> Dim FileName As String
>> Dim Args(1) As new com.sun.star.beans.PropertyValue
>>
>> HOME="/home/<MyUserName>"
>> DirName = HOME & "/Some/Path/"
>> FileName = ConvertToURL(DirName & "/MyFile.csv")
>> ' Get the latest results.
>> Shell(HOME & "/bin/ScriptThatCreatesMyFile.sh", True)
>> Args(0).Name = "FilterName"
>> Args(0).Value = "Text - txt - csv (StarCalc)"
>> Args(1).Name = "FilterOptions"
>> Args(1).Value = "44,34,76,1,,0,False,True,True,False"
>> StarDesktop.loadComponentFromURL(FileName, "_default", 2, Args())
>> End Sub
>>
>> Questions:
>> Exactly what does ”44,34,76,1,,0,False,True,True,False” mean? Where can I
>> find information about this? What is True? What is False? Why is something
>> missing between two commas? Many questions come to my mind…
>>
>> Problems at the moment:
>>
>>    1. The code above seems to treat my file as comma separated. I need TAB
>>    only as separator.
>>    2. The CSV file is imported to a new window. I want it to overwrite
>>    existing (old and outdated) information in columns A:D (without messing
>>    with my conditional and unconditional formatting) on Sheet 0.
>>
>> After som further experimenting I seem to have solved problem 1. It seems
>> lik means Chr(44), which is a comma, and Chr(34) os a double quote. The
>> following line gave me separate columns for every TAB:
>> Args(1).Value = "9,,76,1,,0,False,True,True,False"
>> But what does the rest mean? Chr(76)="L", which seems weird, so I guess the
>> ”76” means something else.
>>
>> I wonder why this kind of information is so hard to find. For easy stuff,
>> when no manual is needed, you can find tons of information, but when things
>> are a bit more cryptic, when a manual is really, really needed, you can
>> search for hours and find nothing, as it seems. Maybe I'm wrong, I actually
>> hope I am, even if I would look stupid… :P
>>
>>
>>
>> Kind regards
>>
>> Johnny Rosenberg
>>
>>

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted