alexpank Posted June 17, 2005 Report Share Posted June 17, 2005 Yup, that's one seriously strange guy... Still, I guess you'd have to be to call yourself 'why the lucky stiff'. Oh well, to each their own, diff'rent strokes for diff'rent folks, it takes all kinds to make a world and all that. BTW (kinda OT) I've got a whole stack of CSV's that I'm looking to convert into another format. Should I use python or ruby or something like that, or is there a better alternative? Quote Link to comment Share on other sites More sharing options...
theYinYeti Posted June 17, 2005 Report Share Posted June 17, 2005 Splitted from https://mandrivausers.org/index.php?showtopic=26192 so as this topic not to go off-topic :) Yves, moderator. Quote Link to comment Share on other sites More sharing options...
neddie Posted June 17, 2005 Report Share Posted June 17, 2005 perl? sed? OpenOffice Calc? Depends a bit on what your "other format" might be, but if you can describe your changes with regular expressions then sed is probably one of the easier ways to go. Quote Link to comment Share on other sites More sharing options...
iphitus Posted June 17, 2005 Report Share Posted June 17, 2005 Just depends on what you are converting to. If you need to use a programming language of some sort, I guess python wouldnt be too bad, it's even got a csv read/write module built in. http://docs.python.org/lib/module-csv.html Quote Link to comment Share on other sites More sharing options...
Hirogen2 Posted June 19, 2005 Report Share Posted June 19, 2005 Text::CSV http://search.cpan.org/~alancitt/Text-CSV-0.01/CSV.pm You could transform a CSV into a '\0' separated using something like perl -MText::CSV -lne 'INIT{$c=new Text::CSV}$c->parse($_);print join("\x00",@{$c->fields()})}' ..Untested.. Quote Link to comment Share on other sites More sharing options...
alexpank Posted June 19, 2005 Author Report Share Posted June 19, 2005 Ta for splitting that off, Yves. I know, I know, I should've done it myself *flinches in preparation for beating* To give a bit more detail, I've got a bunch of CSVs from MS (yes, I have sold my soul to the devil), which are basically the text strings from most of their programs, with the English and Japanese versions in separate fields. What I want to do is convert those CSVs into something like [I]Japanese text[/I] /English text/ (file that it came from) -- the formatting's to do with a dictionary program I use. There are a number of other fields in the CSV, but i was just going to throw them out. So, given that info, is python still a good option? TIA (and apologies for the OT post...) Alex PS (more OT) MS puts out these files so that they can 'ensure consistency in translation' for third-party programs, but I've found countless situations where, for no apparent reason, their own files are inconsistent! Not that this suprises me - MS making dodgy software? :o Quote Link to comment Share on other sites More sharing options...
neddie Posted June 21, 2005 Report Share Posted June 21, 2005 If the input file is of the form english,japanese,other,ignored,fields then you could convert all the commas to spaces with something like this: sed "s/,/ /g" inputfile.csv To convert to the kind of format you want, you could do something like this: sed "s/^\([^,]*\),\([^,]*\),.*$/\[i]\2\[\/i\] \/\1\//" inputfile.csv where in this case the first two fields are swapped with a [ i ] and [ /i ] around the japanese and / and / around the english. I'm not quite sure how to get the filename but that should get you started. Quote Link to comment Share on other sites More sharing options...
alexpank Posted June 21, 2005 Author Report Share Posted June 21, 2005 Thanks for that, neddie. I've been reading a little bit about gawk, and I might see if that can do it too. I have a feeling that the filename (or something liek that) might be one of the fields, so I could get around it that way. Thanks for your help! Alex Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.