Sorting a csv file school project
I have a final project I need to complete so I can move on to the next semester. It would be greatly appreciated if someone could help with my final project. So here is my third question I'm working on.
Using a csv file, provide a single command line that will list the number of times each city name is present, in descending order. An example of the output:
Here are some of the entries of the file:
85724,Arizona Medical Center,520
85099,Arizona State Lottery,602
85287,Arizona State University,480
85324,Black Canyon City,928
85324,Black Cyn City,928
86503,Canyon de Chelly National Mo,928
85643,Chiricahua National Monument,520
86045,Coal Mine Mesa,928
Look up "cut", "sort" & "uniq".
I am not that familiar with awk, however I believe that will do it as well.
This is what I've been using...
I have used this sort -r | uniq -c -f2 az.csv
No go gives me no sort on the count and the city name. I know nothing about awk. I have several more questions I have to do so if this is easy for you how bout you hook me up with the code. I'm trying to make it to next semester not just pass a classes I have 5 others I'm working on too.
And I essentially gave you the answer...if you read the man pages, and pay attention to what those flags do, you'll have your answer. Did you read the man pages, and read what those flags do?? propofol also suggested the cut command instead of awk, which will also work. The flags on the cut command would be "-d" and "-f". Break the problem down:
Ok my bad and maybe your not a bro, my bad once again. Anyhow, I've been trying all sorts of combinations and nothing would sort the count. I'll give this a try and I should've posted what I tried. I've been reading the man pages and my book. So i tried to figure it out on my own with no help and so far I think I've been doing pretty good. I'll give it one more try and see if yours works. Thank you I do greatly appreciate all your help. Just a little frustrated. I'll reply with what happens next in a bit.
That was exactly it! I was on the right track. I used those commands once before but I had them in the wrong order. I appreciate the help. Now I'm onto the question. But going to scrap this one out on my own for a bit and see how far I get until the frustration sets in.
Breaking a task down like this is always the best way to get it done. Once you figure out the what needs to happen, the commands are usually easy to follow after that. You were definitely on the right track, though.
|All times are GMT -5. The time now is 06:35 AM.|