Export tensorboard (with pytorch) data into csv with python
I have Tensorboard data and want it to download all of the csv files behind the data, but I could not find anything from the official documentation. From StackOverflow, I found only this question which is 7 years old and also it's about TensorFlow while I am using PyTorch.
We can do this manually, as we can see in the screenshot, manually there is an option. I wonder if we can do that via code or it is not possible? As I have a lot of data to process.


With the help of this script Below is the shortest working code it gets all of the data in dataframe then you can play further.
import traceback
import pandas as pd
from tensorboard.backend.event_processing.event_accumulator import EventAccumulator

# Extraction function
def tflog2pandas(path):
    runlog_data = pd.DataFrame({&quot;metric&quot;: [], &quot;value&quot;: [], &quot;step&quot;: []})
    try:
        event_acc = EventAccumulator(path)
        event_acc.Reload()
        tags = event_acc.Tags()[&quot;scalars&quot;]
        for tag in tags:
            event_list = event_acc.Scalars(tag)
            values = list(map(lambda x: x.value, event_list))
            step = list(map(lambda x: x.step, event_list))
            r = {&quot;metric&quot;: [tag] * len(step), &quot;value&quot;: values, &quot;step&quot;: step}
            r = pd.DataFrame(r)
            runlog_data = pd.concat([runlog_data, r])
    # Dirty catch of DataLossError
    except Exception:
        print(&quot;Event file possibly corrupt: {}&quot;.format(path))
        traceback.print_exc()
    return runlog_data
path=&quot;Run1&quot; #folderpath
df=tflog2pandas(path)
#df=df[(df.metric != 'params/lr')&amp;(df.metric != 'params/mm')&amp;(df.metric != 'train/loss')] #delete the mentioned rows
df.to_csv(&quot;output.csv&quot;)

