How to import web csv file in calc directly using macro (Sheet from file)

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Lovepreet323
Posts: 19
Joined: Fri Jun 17, 2022 9:45 am

How to import web csv file in calc directly using macro (Sheet from file)

Post by Lovepreet323 »

Please advise How to import web csv file in calc directly using macro (Sheet from file).
Also Csv file web link contains dates, which changed to new dates, means today's date changed to next day date tomorrow.
OpenOffice 4.0 on Windows 10
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: How to import web csv file in calc directly using macro (Sheet from file)

Post by FJCC »

I can load a new document with the content of a csv file on the web with this macro:

Code: Select all

oDoc=Stardesktop.loadComponentFromURL("https://raw.githubusercontent.com/path_to_file/MyFile.csv", 0, "_blank", Array())
I do not understand your second sentence. Do you mean that Calc is changing the dates in the file or that the file on the web will change every day?
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Lovepreet323
Posts: 19
Joined: Fri Jun 17, 2022 9:45 am

Re: How to import web csv file in calc directly using macro (Sheet from file)

Post by Lovepreet323 »

The file on the web and web link itself changes everyday. File name will remains same like "MARKETDATA.csv"
But web link changes like "https://__________?__=__&FromDate=29/06/2022&UptoDate=05/07/2022"
Dates also constantly change in 7 day range only. Next day it will change ""https://__________?__=__&FromDate=30/06/2022&UptoDate=06/07/2022""
how can we pull data from these type of link with macro
OpenOffice 4.0 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to import web csv file in calc directly using macro (Sheet from file)

Post by Villeroy »

Download the file as MARKETDATA.csv, link a sheet to the file, replace the file next day and update the link.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Lovepreet323
Posts: 19
Joined: Fri Jun 17, 2022 9:45 am

Re: How to import web csv file in calc directly using macro (Sheet from file)

Post by Lovepreet323 »

Sir can't we do it with macro itself automatically?
OpenOffice 4.0 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to import web csv file in calc directly using macro (Sheet from file)

Post by Villeroy »

All you need is a script to download the file and replace the old one. The rest happens automatically without office macro.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Lovepreet323
Posts: 19
Joined: Fri Jun 17, 2022 9:45 am

Re: How to import web csv file in calc directly using macro (Sheet from file)

Post by Lovepreet323 »

Please share script if any
OpenOffice 4.0 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to import web csv file in calc directly using macro (Sheet from file)

Post by Villeroy »

You can do that manually once per day.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Lovepreet323
Posts: 19
Joined: Fri Jun 17, 2022 9:45 am

Re: How to import web csv file in calc directly using macro (Sheet from file)

Post by Lovepreet323 »

When i used your macro and changed url to mu own it shows error "URL seems to be an unsupported one"
Please help
OpenOffice 4.0 on Windows 10
User avatar
Mr.Dandy
Posts: 427
Joined: Tue Dec 11, 2012 4:22 pm

Re: How to import web csv file in calc directly using macro (Sheet from file)

Post by Mr.Dandy »

What kind of URL do you means?
Please upload a screenshot with this error.
OpenOffice 4.1.12 - Windows 10
Post Reply