Skip to content

Instantly share code, notes, and snippets.

@alphajc
Created May 30, 2020 01:55
Show Gist options
  • Save alphajc/737357b9a5dda0642f8885a14e81bdae to your computer and use it in GitHub Desktop.
Save alphajc/737357b9a5dda0642f8885a14e81bdae to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import pandas as pd
df = pd.read_csv(sys.argv[1])
last = ''
for row in df[df['Vpc名称'].notna()][df['主IPv4公网IP'].notna()].sort_values(by=['Vpc名称']).iterrows():
if last != row[1]['Vpc名称']:
print()
print('[' + row[1]['Vpc名称'] + ']')
last = row[1]['Vpc名称']
print(row[1]['ID'], 'ansible_host=' + row[1]['主IPv4公网IP'], '\t#', row[1]['实例名'], row[1]['主IPv4内网IP'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment