-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurlsplit.py
43 lines (39 loc) · 1.12 KB
/
urlsplit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
Created on Thu May 7 09:00:53 2015
@author: ayssi
Ce script traite tout type de fichier log et crée par la suite un fichier CSV
"""
## Ezproxy Log : Outputs a file with these columns:
## Ip Address
## Session
## # Login
## date
## # URL
## ## ## Database
## ## ## DOI
## ## ## ISSN or ISBN
## ## ## Ressourc Type : TOC, Book or Article
## ## ## Ressourc Format : html, Pdf
## % Stat
## # Size
import os
import sys
import configparser
import re
import csv
output_csvfile = open("outurlsplit.csv", 'w', newline='')
headers=["IP Address","session","Login","date","Database","DOI","ISSN or ISBN","Resource type","Ressource format","Stat","Size"]
data = csv.writer(output_csvfile, delimiter=';', quoting=csv.QUOTE_NONNUMERIC)
print("les ligne du fichier sont de type :",type(data))
with open("test.csv") as f:
f_csv = csv.reader(f, delimiter=';')
next(f_csv, None) # skip the headers
data.writerow(headers)
i=0
for row in f_csv:
if re.match("eressources",row[i]):
print ("cette ligne a été ignorée !")
else:
data.writerow(row)
i +=i