#!/usr/bin/perl # Usage: ./solar_01.pl < forecast_file.csv # where each data row from the csv file has the following format: # # PvEstimate,PvEstimate10,PvEstimate90,PeriodEnd,Period # 0.4645,0.3248,0.5801,2022-11-03T11:00:00Z,PT30M my $line_number = "0"; my @csv; # Read from standard input and process each CSV line sequentially. while ( my $line = <>) { # Remove Windows-style EOL $line =~ s/\R/\012/; chomp ($line); # Split each row of the CVS file and get the fields we want. my ($power,$timestamp) = (split "," , $line)[0,3]; ${csv[$line_number]}{"power"} = $power; ${csv[$line_number]}{"timestamp"} = $timestamp; ++$line_number; }