Ask Your Question
0

Is it possible to save text-files import specifications in calc?

asked 2018-03-24 18:47:10 +0200

MSpina gravatar image

I need to do recurring import of text files with the same format into Calc, but every time I got to specify their fields format; is there a way to get them saved and reusable?

edit retag flag offensive close merge delete

Comments

I don't think that it is possible without a macro.

gabix gravatar imagegabix ( 2018-03-24 19:22:39 +0200 )edit

@MSpina: Doesn't your import dialog remember the previous settings?
Beyond that, I'm afraid, there is no way to set defaults, not to speak of a kind of dropdown with selectable named items.
@gabix: Do you know an interface or a service of the API for the purpose (and also for 'Text to Columns...') and a way to use it from a "macro". Or did you mean a complete re-implementation by the macro?

Lupp gravatar imageLupp ( 2018-03-25 12:49:38 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2018-03-25 11:28:53 +0200

m.a.riosv gravatar image

Maybe this extension can help Import csv

edit flag offensive delete link more

Comments

Shouldn't the application itself come with that kind of features on board? Do you know a feature request like 'Implement import styles and Tect-to-Columns styles'?

Lupp gravatar imageLupp ( 2018-03-25 12:57:53 +0200 )edit

Tank you. That's precisely what I meant. (Five years old and not upvoted once, Should actually nobody need that?)

Lupp gravatar imageLupp ( 2018-03-25 19:37:44 +0200 )edit

I think because many times we import the same file, and if it is linked, options are preserved. Or with new files, last options are preserved except those for fields, but if the appropiatted language is selected, no intervention it's needed, except to retain as text for some field with numbers.

m.a.riosv gravatar imagem.a.riosv ( 2018-03-26 01:14:34 +0200 )edit

@m.a.riosv: many thanks, that's what I was searching for! @Lupp, @gabix: thanks to you as well.

MSpina gravatar imageMSpina ( 2018-03-26 13:50:31 +0200 )edit
0

answered 2018-03-26 08:21:45 +0200

gabix gravatar image

I have to post it as an answer because of a limitation on the comment size. However, this is not a real answer, rather a comment to Lupp's comment to my initial comment.

I have a couple of macros to load specific CSV files with specific preset options, here is one example:

Sub loadES 
oDesktop = createUnoService("com.sun.star.frame.Desktop") 
sUrl = "file:///e.csv" 
sUrl2 = "file:///i.csv" 
Dim mFileProperties(2) as new com.sun.star.beans.PropertyValue 
mFileProperties(0).Name = "FilterName" 
mFileProperties(0).Value = "scalc: Text - txt - csv (StarCalc)" 
mFileProperties(1).Name = "FilterFlags" 
mFileProperties(1).Value = "FIX,,30,1,0/2/13/2/50/2/53/10/65/10" 
oDocument = oDesktop.loadComponentFromURL(sUrl, "_blank", 0, mFileProperties()) 
oDocument2 = oDesktop.loadComponentFromURL(sUrl2, "_blank", 0, mFileProperties()) 
End Sub

The macro is very crude but worked for me for many years in OpenOffice.org. However, it does not work in LibreOffice. Blame the developers for yet another broken thing. Thus, either use Apache OpenOffice (my firm general recommendation when it is about spreadsheets), or find a way to circumvent, or, well, pressure on the developers to repair the API.

edit flag offensive delete link more

Comments

(I won't spend much more time with this thread since I never imported csv via "macros".)
@gabix: You may throw a glance at https://api.libreoffice.org/docs/idl/... and probably to https://api.libreoffice.org/docs/idl/...
Well, you're right. That's not what we would call a clear and sufficiently complete documentation.

Lupp gravatar imageLupp ( 2018-03-26 13:02:45 +0200 )edit

@gabix: AOO Calc also has lots of bugs of which rarely one is fixed. A relevant number, however, of the common heritage were resolved for LibO. LibO cared for healthy new blood, of course. I would judge there was a net improvement nonetheless. A few new incompatibilities may have been unavoidable.
(You surely learned to avoid mined terrain in AOO for a long time.)

Lupp gravatar imageLupp ( 2018-03-26 13:08:29 +0200 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2018-03-24 18:47:10 +0200

Seen: 84 times

Last updated: Mar 26 '18