Skip to content

Instantly share code, notes, and snippets.

@fubrasp
Created March 4, 2020 21:42
Show Gist options
  • Save fubrasp/ce8a504fd6d8d0b7e5aa37ff85c8015c to your computer and use it in GitHub Desktop.
Save fubrasp/ce8a504fd6d8d0b7e5aa37ff85c8015c to your computer and use it in GitHub Desktop.
examples
Get-Process Chrome -ErrorAction SilentlyContinue | Stop-Process -Force
import os
os.system('powershell C:/Users/33640/PycharmProjects/testFrancoisBotTwitter/chromekiller.ps1')
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from models.student import *
if __name__ == "__main__":
students = Student.read_students()
first_student = students[1]
first_student.write_myself_in_csv()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import csv
import pandas as pd
class Student:
def __init__(self, name, first_name, student_id, section):
self.name = name
self.first_name = first_name
self.student_id = student_id
self.section = section
def __str__(self):
return "Nom {}, Prénom {}, ID étudiant {}, Section {}." \
.format(self.name, self.first_name, self.student_id, self.section)
@staticmethod
def read_students():
file_name = input("Nom du fichier a afficher ? \n")
students = []
with open(file_name, newline='') as csv_file:
reader = csv.reader(csv_file, delimiter=';', quotechar='"')
for line in reader:
student = Student(line[0], line[1], line[2], line[3])
students.append(student)
# print(student.__str__())
return students
def write_myself_in_csv(self):
df = pd.DataFrame({'Nom': [self.name],
'Prénom': [self.first_name],
'ID_étudiant': [self.student_id],
'Section': [self.section]})
print(df.to_csv(index=False))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment