Sep-06-2023, 12:22 PM
(This post was last modified: Sep-06-2023, 12:22 PM by deanhystad.)
No problem. Same solution with a string. Why did you mention touchstone files in the OP?
import pandas as pd from io import StringIO # Might need to use TextIO for input from GPIB. gpib_string = """# 34589043! FILE NAME ! DATE NOW ! RAW DATA # More information ! FREQ S11M S21M S21A 0.11444405920970335 0.22851792934978143 0.16724464908750036 0.054813079444560264 0.11565032195951042 0.23010933442970138 0.3048773751796404 0.11465260170716174 0.20102541854079847 0.27830101316888567 0.3995954975408248 0.12034618280172404 0.41276142607996513 0.31147127777115224 0.46636510024384636 0.2806783250819618 0.495356229079312 0.3495931528852747 0.6389401268977468 0.38079631999232333 0.556074773658631 0.3894689120388013 0.6779475794713076 0.43728550829612134 0.6332585933784733 0.4924761223011904 0.7503465368809027 0.7386632480838207 0.6341059239183447 0.5130383410762516 0.8554371206142789 0.7695854491274398 0.8902822004610119 0.7219019187548961 0.8712110079483135 0.8443884202719537 0.9170577193238573 0.7970927214052331 0.9344766589022325 0.8597198838156557""" # Read column names from 4th line in string. Remove leading "!" columns = gpib_string.split("\n")[4][1:].split() # Read file into dataframe. Skip the first 5 rows and use the column # names from above. df = pd.read_csv(StringIO(gpib_string), sep="\t", skiprows=5, names=columns) print(df)