-1

I have a .txt file as follows:

C:\Temp\stick\zNsNo-MAGNETRON\MAG-ZnSnO-1-XPS.vms

None
    Characteristic Energy eV    1486.7  Acquisition Time s  3
KE_None BE_None CPS_None    Background_None
1472.7  14  735 735
1472.8  13.9    708 708
1472.9  13.8    725 725
1473    13.7    699 699
1473.1  13.6    734 734
1473.2  13.5    738 738
1473.3  13.4    776 776
1473.4  13.3    785 785

and am trying to extract the numbers under "KE_None" into a list and the numbers under "CPS_None" to eventually plot them against each other. I am finding it hard to get those two lists while excluding the other numbers under "BE_None" and "Background_None" while also ignoring the first few lines of the file. Hope you can help. This is what I have so far which imports the text as a whole.

My current code:

Code so far

mozway
  • 194,879
  • 13
  • 39
  • 75
  • 1
    [Please do not upload images of code](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question). – Da Chucky Oct 13 '21 at 11:20

1 Answers1

0

While you could do this with lists in pure python, this is really a job for specialized libraries like pandas

import pandas as pd   ## not part of default modules, needs to be installed

df = pd.read_csv('C:\Temp\stick\zNsNo-MAGNETRON\MAG-ZnSnO-1-XPS.vms',
                 skiprows=2, sep='\s+')
df.plot.scatter(x='KE_None', y='CPS_None')

output:

scatter plot

mozway
  • 194,879
  • 13
  • 39
  • 75