Import output from URL as text to Writer/ODT - update on opening or by request

In a ODT I would like to import the content from a online URL (varying a filter to get various single cell contents, output can be CSV or JSON) into different places in the text. The imported content should float with the surrounding text and be formatted in the same style. As well the content should be updated with every opening of the the ODT and/or by request triggering a certain command (best with the GUI).
I found various hints regarding DDE, Fields and the function CSVLOOKUP, but no solution gave the result I’m searching for. Since I’m not a coder I have limited possibilities to create scripts by myself and only solutions completely working in the ODT (also when opening on another system) are interesting. I use LO v7.5.1.2 Win.

I guess there no one else has this need or there is no possibility to do this in LO Writer?
It is fairly sad if I need to look if M$ Word does support this.

Sorry, I can not understand, what you want to achieve in this case. Writer and CSV? The .csv format is one the export/import format of the Calc application. How it is related to the .odt file format of the Writer?

I try to explain in more detail. Having the same Text-Snippets in 3 languages in various output locations I’m trying to setup a solution which has a quite easy administration and editing.
For the Text-Snippets I’m using an online spreadsheet and I opted for Google Spreadsheet because user access control, online publication/access and output filtering is good. gives access and there is also the option for json and html output and as well SQL style filtering for example with &tq=SELECT+B+WHERE+A+CONTAINS+%27ID-Key%27+ORDER+BY+B
The CSV/array fields can also contain HTML code with URLs so interpreted output as such would be needed in those cases.
The CSV output allowed to import the array of data (one id/key and 3 language columns) into two Online-CMS (one FOSS/PHP and the other Proprietary/Script) and making them available via easy shortcode using snipped-name (id/key) and language as filters.

I tried to achieve the same in a Writer document. I have no real coding experience so I tried ChatGPT which offered a range of solutions but none did work so I wonder if M$ is behind this or LibreOffice just does not support this case? :wink: Among the proposed solutions I tried:

WEBSERVICE(URI) or FILTERXML(XML Document; XPath expression): the sample in the documentation =FILTERXML(WEBSERVICE(“MediaWiki API result - The Document Foundation Wiki”) did work in Calc but never in Writer > Fields > Variables > Formula. The Google CSV (or json or html) output did not work in Calc.

As a variant of a Field solution for Variables > DDE after giving a name like “snippet1” in the “Command” field, the following string was proposed:
=DDE(“soffice”;“";"grep -i -m1 ‘^“snippet1_de,”’ | cut -d, -f2”)
I also tried‘snippet1’+ORDER+BY+B

I also tried solutions by creating a Macro script which loads the snippet CSV into an array and makes it available for output and received multiple solution proposals mainly in Basic Script but none worked for me. Mostly the Basic Syntax seems to be wrong beggining with the correct loading of the online CSV etc. it never seemed to work without heavy debugging/recoding. Anyway solutions based Macros seemed to be less attractive because of the uncertainty how well they can be opened on various systems.

So for now I gave up.

Open for solution proposals.

Your first link not work.

Mostly the Basic Syntax seems to be wrong beggining with the correct loading of the online CSV etc. it never seemed to work without heavy debugging/recoding.

Can you upload your macro code?

Anyway solutions based Macros seemed to be less attractive because of the uncertainty how well they can be opened on various systems.

Do you mean “systems” as operating systems? The StarBasic+API code will will work on every supportad operating systems - inside the LO. (But it will not work in MS Office - if you meant that)

Let’s start with the easy part:

The tool is not suited for coding, as it can invent code and forget parts. The last part could be repaired, if you know to read code, but the first is trouble, as it will use not available commands and leave it to you to find out the command is not available. So it has the same coding level you seem to have: Try and error.
LibreOffice, like OpenOffice and MS-Word/Excel are desktop programms with added connectors to the internet or databases. Google used the work-model, but invented a lot of new commands to access web-resources, wich not necessarily exist in other office suites. Also Word/Excel has several tools to replace databases, as most users don’t have/use access. LibreOffice is shipped with a database component for free, so it often surprises MS-users to find/see Base used for example with mail-merge. As a result the Suites differ in this parts and solutions are not portable between M$- Google- Open/LibreOffice…

It is quite certain, they can not be used with other suites, even as LibreOffice has a compatibility mode for vba. But as LibreOffice itself is portable I can use it with its macros on Windows/Linux/MacOS.

What you may try is to import the data to Calc, where you can pre-process them. Then you may use a DDE-reference to areas of the Calc-file and import this to Writer.

I’d suggest to put the imported text in frames and use a separate set of styles for this. ( They may be identical to the styles for the other text, but so they can be changed indepently. )

You may have ruled out possible solutions yourself here, by asking for a tool to write books as the only place you are interested in to handle json/csv-data from the net. Macros could solve the problem then, but you seem not to like this way also. And to tailor them, one would need much more information on the data you wish to process, as there are various formattings possible…

@Zizi64 The GS link was intentionally not working. I now made an example sheet to try with the same structure:

Regarding Macro code I will se which one might be the best approach and if sharing makes any sense - see response to Wanderer.

About Macro solutions being less attractive (then simple fields with Online-CSV-Import by request) I mean because of security settings and knowlege needed by the user how to change settings and then run a macro etc. If the solution does not work simply within a “TEMPLATE” ODT file maybe with one simple user interaction then copy and paste might sadly remain the better way - one LO user has no willingness to learn any advanced usage/skills. For example he has no clue about setting up and using styles and regularly “destroys” template ODTs or even uses older versions just because easier to edit.

@Wanderer and flawed ChatGPT coding: I noticed that for LO this is the case. But as said for two online CMS (PHP and proprietary scripting) it worked surprisingly well, not with the first ChatGPT answer but I was able to make it perfectly working with some minor tweaking.

About Macro unattractiveness see above. In addition I like to keep high security settings on every system, even with Linux/LibreOffice.

Calc to pre-process and then DDE-reference in Writer: I know this might work but this kills the usefulness as I would have to do at least some manual routine with every update in the Google Sheet (or when a setup on a new system is necessary) while the goal would be to have the text-snippets updated from the online source automatically (in the document). I can not imagine this will work easily when used in different systems (Windows, Linux, etc.)

Separate style for imported data: It is a good idea for debugging etc. but I think this is the last concern as all other steps before need to work.

Solutions completely working in the ODT: I explained why above in this response, Macros can be the solution but I would prefer a built-in standard solution. I might even looking into coding a Extension/Plugin and installing it on every workstation - but with my knowledge this seems way over my skills.
Except for one project phase working in a different IT-Environment I never went to other suites then LibreOffice in the last 10 years - using mainly Writer and Calc. But at this point for this case I might look if Google Docs or M$ Word could offer an easy solution for this case. Because I’m using SVG images in the document I would like to avoid this, because only LO has good support when exporting to PDF. Additionally I have text wrapping around custom shapes, which in Google Docs is not supported.
But having an as much as possible automatic solution to create a well styled PDF document from the up to date online text snippets is the priority in this use case.

seems to contradict MS-word as in

You may either choose MS or Linux, not both - or you need to use an online-office.

@Wanderer You are right. But if it is not possible to achieve what I outlined in LO for me I may restrict the OS/Office setup, just to create those PDFs. My guess is this will be done 2-8 times per year for 18-36 files, currently the files are just not updated more then every 1-3 years. Using something different then LO must not mean dropping LO generally, but certainly it is unfortunate.

EDIT: certainly a LO online solution with easy sheet/Calc data access (including user/edit rights management) would be attractive, but I understand it is difficult not only for the coding/functionality side, but mainly the hosting (compatibility, performance, monthly costs).

I want to try this way, as Google Docs is too limited for layout and I do not like to try M$O. Google Sheets lets export to ODS, but for the DDE Links so far I have not found a way to “filter” by a column instead of a “fixed link”. I opened a new topic as not directly related to this one here (URL CSV to Writer):

Writer DDE-Link to a ODS cell in column B filtered by name/key/id in column A possible?