Read sample CSV file as dataframe
parent
eeaad6bb23
commit
51afbfc867
|
@ -78,6 +78,8 @@ rx_tools
|
|||
# Upstream
|
||||
Sections of code and clues from Cees Bassa.
|
||||
|
||||
* https://github.com/cbassa
|
||||
|
||||
Primary author and errors in code from Jeff Moe.
|
||||
|
||||
|
||||
|
|
36
polar-plot
36
polar-plot
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# polar-plot
|
||||
#
|
||||
# Copyright (C) 2023, Jeff Moe
|
||||
# Copyright (C) 2022, 2023, Jeff Moe
|
||||
# Copyright (C) 2023, Cees Bassa
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
@ -22,15 +22,45 @@
|
|||
# Generate graphical plot of radio interference.
|
||||
#
|
||||
# Usage:
|
||||
# polar_plot
|
||||
# polar_plot [filename]
|
||||
#
|
||||
# Example:
|
||||
# polar_plot
|
||||
# ./polar-plot data/sample.csv
|
||||
# ./polar-plot data/rtl_power-sample.csv
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import pandas as pd
|
||||
import sys
|
||||
import re
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Determine what type of file to load to dataframe
|
||||
datafile = sys.argv[1]
|
||||
|
||||
with open(datafile) as f:
|
||||
firstline = f.readline().rstrip()
|
||||
|
||||
if firstline == "1, -38.93":
|
||||
print("Test data from sample.csv")
|
||||
df = pd.read_csv(
|
||||
datafile, skiprows=0, usecols=[0, 1], names=("Azimuth", "Energy")
|
||||
)
|
||||
|
||||
elif re.match(re.compile("20*"), firstline):
|
||||
print("rtl_power CSV file. Not yet supported.")
|
||||
exit()
|
||||
|
||||
else:
|
||||
print("Unknown file type.")
|
||||
exit()
|
||||
|
||||
# Print the Dataframe loaded from CSV
|
||||
with pd.option_context("display.max_rows", None, "display.max_columns", None):
|
||||
print(df)
|
||||
|
||||
# (Empty) Plot here
|
||||
fig = plt.figure(figsize=(8, 8))
|
||||
ax = fig.add_subplot(111, projection="polar")
|
||||
|
||||
|
|
Loading…
Reference in New Issue