CSV File Data

Plotalot can retrieve data from a CSV file instead of a database. You can specify a query like this:

FILE tmp/plotalot_data.csv

The query must start with the word "FILE" (case insensitive) followed by a single space, followed by a file path. If the file path starts with a forward slash ( "/" ) the path is assumed to be absolute. If the file path does not start with a forward slash it is assumed to be relative to the site root directory. The file can have any name, it does not have to have the .csv extension. File names may contain spaces but make sure there are no spaces or other invisible characters after the file name.

The file must be comma or tab delimited, and is assumed to have a heading row with at least the number of columns required by the chart. All other rows must have the same number of columns as the heading row. Files may have more columns than required. Additional columns to the right are ignored, but the leftmost column is always treated as the first column.

A simple example of a CSV file would be like this:

Column 1 Column 2
1 2
2 3

Plotalot line charts require dates to be in Unix Timestamp format. In Excel you can convert readable dates to Unix Timestamps with the formula: =(A1-DATE(1970,1,1))*86400. For example, if you have a spreadsheet of dates and values, you can insert a new column using the formula above to calculate the Unix timestamp values:

Date Unix Date Value
01/01/23 1672531200 43
02/01/23 1672617600 42
03/01/23 1672704000 42.5
04/01/23 1672790400 33.5
05/01/23 1672876800 31
06/01/23 1672963200 27

You would then need to copy columns B and C to another sheet and save as CSV to obtain a file like this:

Unix date Value
1672531200 43
1672617600 42
1672704000 42.5
1672790400 33.5
1672876800 31
1672963200 27