-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlez3.py
More file actions
45 lines (37 loc) · 854 Bytes
/
Copy pathlez3.py
File metadata and controls
45 lines (37 loc) · 854 Bytes
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
44
45
#13-11-2020
#Read Csv File
myFile = open("shampoo_sales.csv", "r")
print(myFile.read())
myFile.close
#Slice Strings
myString = "superman"
print (myString[0:3]) #carat
print (myString[3:7])
print (myString[0:-1])
#Slice Csv File [0:50]
myFile = open("shampoo_sales.csv", "r")
myFileCont = myFile.read()
if (len(myFileCont)>50):
print(myFileCont[0:50])
else:
print(myFileCont)
myFile.close()
#Read Csv File - line by line!
myFile = open("shampoo_sales.csv", "r")
for line in myFile:
print(line)
myFile.close()
#Write to files
myFile = open("saluti.txt","w")
myFile.write("Ciao")
#String Split
myString = "Ciao, come va?"
elementList = myString.split(",") #['ciao', ' come va?']
print(elementList)
#String to number conversion
myString = "5.5"
myNumber = float(myString)
#Add elements to list
myList = [1,2,3,4]
myList.append(5)
print (myList)