Hello this is #Mastery30 about the usage of visualization with tools, I found on the internet there were some libreries that helped with this and the best 5 were:
1. D3
2. Vega
3.Procesing
4.Gephi
"For people just starting out, I'd suggest starting either with Processing or D3," says Jan Willem Tulp. "Both of them have a very large user base and a great number of examples you can learn from."
The online data visualization community can be good for answering questions. Statisticians may know data, but still be learning the basics of design. Designers may know how to create something that’s aesthetically pleasing, but still be learning about statistics.
So, be sure you select the one you like the best and fulfills all your needs. Some may say java is good too so you can try that one. It is better if you search on google for what you will be needing and be sure it makes all the things you need it to.
]]>
Hello this is #Mastery30 about the usage of visualization with tools, I found on the internet there were some libreries that helped with this and the best 5 were:
1. D3
2. Vega
3.Procesing
4.Gephi
“For people just starting out, I’d suggest starting either with Processing or D3,” says Jan Willem Tulp. “Both of them have a very large user base and a great number of examples you can learn from.”
The online data visualization community can be good for answering questions. Statisticians may know data, but still be learning the basics of design. Designers may know how to create something that’s aesthetically pleasing, but still be learning about statistics.
So, be sure you select the one you like the best and fulfills all your needs. Some may say java is good too so you can try that one. It is better if you search on google for what you will be needing and be sure it makes all the things you need it to.
]]>
You can find my video here:
open(“filename.extension”,”r or w”)
You put r if you are going to read the file
You put w if you want to write the file
There are others parameter you can type there, but those are the basics
So let’s start, I am going to use the 93car.dat.tx the Journal of Statistics Education gives us.
What I want to do, is to delete all those strange number to only left the brand of the car and rthe model
See the original file:
And how I want it to end:
So let’s start
The first thing to do is to open the file in reading mode (that means r at the end of the parenthesis) and to store aaaaalll the data inside a variable inside python, I called it text, after that close it.
Then I will open the file in writing mode to start modifying it, so first, I have to get rid of the even lines.
One way te start reading and changing the lines is with a for loop
for (any variable, I chose line) in (where you stored all the data, in my case is text)
for line in text:
That is the main loop, and since I want to get rid of the even lines, I am going to write the lines only if is even BEACUSE we count the first iteration as one, see that x?
after doing that, close it!
open your file, and you are going to see….. YES!
You have just modified your first file from python!
Now, I don like all those number, so I want to errase them, I know all these numbers start on the position number 30 en every line, so starting over and doing the same process EXCEPT what is inside the for.
You see, what we are going to do inside the for loop is to write each line, but cutted; you see that [0:29]? that means that it is only going to write from the first space to the 29th of each line
And now open your file…. and it has to look like this, you did it!
As you can see, it is very easy, you just write up what you want
]]>
]]>
Reading and writing of files in Python
Writing a file:
To write a file you have to use the same function as before but this time with a different parameter: open(“filename”,”w”)
This “w” thing will thell python that you want to edit/write the file, be careful because this will erase the content of that file and create a new file. To write a line use fout.write() and use as a parameter a string (or a variable with a string), when you are done use fout.close(). It is very important that you understand that the file will star writing in the last empty line. Here is an example:
def process_file(filename):
name = open(“filename”,”w”)
a = “no”
while a == “yes”:
line = input(“Write here the new data”)
fout.write(line)
a = input(“want to close?”)
fout.close()
process_file(“file.txt”)
This function will add new strings to the “file.txt” document until the user decides to stop.
Here’s basically any WSQ we’ve done, in most of them user input is needed.
Mastery 30 – Reading and writing of files in Python
Here’s an example code I made to demonstrate I know how to write and read files in Python.
]]>