Archive

Posts Tagged ‘csv’

convert a LibreOffice Calc/Excel stylesheet to .csv in command-line

November 21, 2015 Leave a comment

Problem
I have a stylesheet made with LibreOffice Calc / Excel. The extension of the file is .ods or .xls / .xlsx. How to convert it to .csv? From the command line, of course.

Solution
Convert an .ods file:

libreoffice --headless --convert-to csv file.ods

Convert an Excel file:

libreoffice --headless --convert-to csv file.xlsx

Tip from here.

If you use --convert-to html, then you get an HTML output.

Categories: bash Tags: , , ,

Currency exchange rates in CSV format

December 8, 2012 Leave a comment

See http://www.bankofcanada.ca/en/markets/csv/exchange_eng.csv.

From the header of the file:

The daily noon exchange rates for major foreign currencies are published
every business day at about 12:30 p.m. EST. They are obtained from
market or official sources around noon and show the rates for the various
currencies in Canadian dollars converted from US dollars. The rates are
nominal quotations – neither buying nor selling rates – and are intended
for statistical or analytical purposes. Rates available from financial
institutions will differ.

How to do the calculation?

Say, we want to convert 1 Euro (EUR) to Hungarian Forint (HUF). Content of the file:

Date, ISO4217, 2012-11-29, 2012-11-30, 2012-12-03, 2012-12-04, 2012-12-05, 2012-12-06, 2012-12-07
European Euro , EUR, 1.2863, 1.2921, 1.2972, 1.2986, 1.2962, 1.2850, 1.2799
Hungarian forint, HUF, 0.004596, 0.004598, 0.004586, 0.004584, 0.004574, 0.004540, 0.004517
...

The latest date here is 2012-12-07 (yyyy-mm-dd), which is in the last column. So the answer is: 1 EUR is 1.2799/0.004517 = 283.35 HUF.

Download financial data using the Yahoo API

December 13, 2010 1 comment

Problem

If you want to consult financial information, Yahoo! Finance is a good site for that. For instance, to get info about Microsoft’s shares, just visit http://finance.yahoo.com/q?s=msft&ql=1. There, in the bottom right corner in the Toolbox section, you can find a link “Download Data”.

But is there another way to get financial data? Is there a Yahoo API for this?

Solution

The answer to the previous question is: yes, there is. Visit http://www.gummy-stuff.org/Yahoo-data.htm for a detailed presentation of the API.

Example:

http://finance.yahoo.com/d/quotes.csv?s=MSFT&f=nl1px

Here we ask stock information about the shares of Microsoft. Their stock code is “MSFT”. We pass four parameters: n – stock name, l1 – current price, p – price at the previous close, x – stock exchange. The data is returned as a text file in .csv format:

"Microsoft Corpora",27.245,27.34,"NasdaqNM"

Special tags:

At http://www.gummy-stuff.org/Yahoo-data.htm, you can find a table with all the special tags. I collected them here, in a single link: copy link (see the link in the status bar).

This can help you to choose the parameters that you really need.

Categories: finance Tags: , , , ,