Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lava_man

macrumors newbie
Original poster
Nov 14, 2016
1
0
I've got a folder full of .CSV files containing my playlist information from Spotify premium that I need to edit before I can upload said playlists into my Google Play Music.

Basically in every file, column "A" needs to be deleted, then the resulting field 1 in column(s) "A" through "D" need to be renamed track, artist, album, and playlist, in that order.

In column "D," all fields under playlist (D2 through however many rows are in the file) I would like the filename to be entered.

Lastly, columns E thru I are unnecessary and therefore should be deleted as well.

I tried "watch me do" in automator, to no avail. So then I began to search through the functions in automator, and couldn't find any sort of actions that would allow me to make such changes.
 
My advice: don't use AppleScript, unless your goal is to directly interface with applications which do publish an AppleScript dictionary - and even then, I would try using the Javascript variant instead of Applescript proper. There seems to be less information online about how to do that than for AppleScript, but still I bet it will be less frustrating/more productive in the mid and long term.

Anyway, what you want to do sounds like could be done manually in any spreadsheet program in 3 minutes. If you really want to do it with a script, I'd try Python - or Ruby, or Javascript.
 
Post a sample of the actual data, say at least 25 lines.

Please use CODE tags when posting the data,
OR
Add a text file as an attachment to your post.


Given just your description, it sounds eminently doable in 'awk'. But to create an awk program, one needs data to be processed. While one could create test data, it's best to use the actual data in question.


Also, since you say the data is in multiple CSV files, post the list of files to be processed. We need to see if they follow a naming convention, such as all having a ".csv" extension, or whether something else will be needed. To list all the files in a folder, type this into a Terminal window, with a single space at the end, and no RETURN key:
Code:
ls -l
Then drag the folder containing the CSV files over the Terminal window and drop it. Terminal should expand the dropped folder to the pathname of that folder.

Then activate the Terminal window and press the RETURN key.

Copy and paste the output, with CODE tags around it.
 
  • Like
Reactions: superscape
Sounds like chown33 has the most elegant approach. I agree that AppleScript is probably not the way to go.

You can probably use Automator to add a slightly more user friendly front end onto the awk command if this is something you're likely to do several times again.
 
You can probably use Automator to add a slightly more user friendly front end onto the awk command if this is something you're likely to do several times again.
Yup, it's in my plan.

Automator is a good way of turning a command-line into a drag-n-drop app. It's also a good way to make Folder Actions or just a double-clickable app from a command-line.
 
Oh God. I recommended not to use AppleScript because it's a pain - and people are recommending AWK??

There are tons of modern, in use, non-obscure, non-broken scripting languages. I already mentioned Python, Ruby, Javascript. There's still Lua, TCL - most of them famously easy to get into, and even with options for GUIs and full programming facilities (will you want to automatize the uploads after you finish processing those lists?).

But still people go for the 40-year old beasts with multiple, partially incompatible versions, which start their manuals with a "Dark Corners" section?

Well, at least no-one recommended Bash - yet! :D
 
But still people go for the 40-year old beasts with multiple, partially incompatible versions, which start their manuals with a "Dark Corners" section?

Well, at least no-one recommended Bash - yet!

Well I would have started this idea for myself with a bash script that processed all the files with one of them stodgy old time tested and proven commands you denigrate in your post.
 
  • Like
Reactions: superscape
Well I would have started this idea for myself with a bash script that processed all the files with one of them stodgy old time tested and proven commands you denigrate in your post.

Yeah, exactly as I have done too many times - and the result is always the same: too much time and hair wasted for the functionality I got.

If the OP is going to *learn* a scripting language, going to AWK is idiotic. It's in itself less idiotic than learning Bash, but since he will *also* need Bash really soon to do anything non-trivial with AWK, the hole of idiocy starts to grow.

Meanwhile, someone who started in Python, or JavaScript, or lots of others, could do things in a sane environment and grow the program without any limit. And even if he only wants limited functionality I bet he would end faster.

Now, if the OP already knew AWK and/or Bash *and* can do his thing in less than a handful of lines as a one-shot thing, then *maybe* it'll be OK. But then he wouldn't be asking. And if the task was so easy anyway, he could have done it in 3 minutes manually in any spreadsheet program - as I already said earlier.

For the record: I *wish* that whenever I was about to start any of my AppleScript of Bash scripts someone had whacked me over the head until I used *anything* saner. Which is why I am doing it now.
 
  • Like
Reactions: 960design
If the OP is going to *learn* a scripting language, going to AWK is idiotic. It's in itself less idiotic than learning Bash, but since he will *also* need Bash really soon to do anything non-trivial with AWK, the hole of idiocy starts to grow.

The same can be said of any of those other languages you refer to as well, best he just sit back and be spoon fed a GUI by someone and never learn how his computer works.

Edit: I would add this is what awk was designed for cutting out fields/columns in a text file on a command line or in script. The old *nix one tool for the job that does it well theory that is the basis of its design philosophy originally..
 
Last edited:
The same can be said of any of those other languages you refer to as well,

Do any of those languages *start* their manual with a "Dark corners" warning and quote from the language creator, like AWK does?

Bash is even worse! :D

best he just sit back and be spoon fed a GUI by someone and never learn how his computer works.

I'm talking here about using languages that can *create* GUIs (unlike AWK or Bash) - and you talk about being spoon-fed GUIs? ... what??

And, pray tell, how will AWK or Bash help anyone learn "how the computer works"? :D
 
If the OP is going to *learn* a scripting language, going to AWK is idiotic.
I agree with you. I'd qualify it slightly, however, as "going to AWK first is idiotic".

Good thing I didn't actually suggest he learn awk. I suggested that awk was capable of doing this. And since I know awk, I was willing to contribute code to solving this particular problem. The OP didn't need to learn awk, and any awk I posted I was completely willing to explain.

Automator was the second prong in my plan. See my above post.

However, since the OP hasn't posted any data, and the description is a bit vague for me to start thrashing at it or fabricating sample data, I don't see any point to dragging this out further. I have no interest in arguing about the most suitable language to learn first, or to solve this particular problem. Until some actionable data is posted, I'm out.
 
Last edited:
  • Like
Reactions: Sko and jaduff46
This is why no further comment from me after chown33's original suggestion.

Right tools, don't need Python or another language, easy to test (dump into Excel and see if the formatted output is correct).

JD
 
I've been programming for 20 years -- One reason I love it -- if the solution is agnostic to the problem, there is more than one way to skin a cat. Almost NOTHING I do anymore, is from scratch, so its whatever tools I have and how close it is to another solution == productivity.
 
  • Like
Reactions: jaduff46
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.