|
This topic comprises 2 pages: 1 2
|
Author
|
Topic: How to replace "The Movie Title" with "Movie Title, The" in Excel
|
|
Paul Mayer
Oh get out of it Melvin, before it pulls you under!
Posts: 3836
From: Albuquerque, NM
Registered: Feb 2000
|
posted 08-31-2011 12:17 AM
Apparantly there is an old Excel add-in out there that provides several additional ways of sorting, including one called "xArticles" which excludes leading "A", "And", and "The" when sorting. Should be perfect for sorting movie titles...
Click here
[Edit] Here's another suggested free Excel add-in and formula to use:
quote:
Here's a non-commercial solution. Download and install Longre's free morefunc.xll add-in from http://xcell05.free.fr To set up a helper column, where "the", "a", or any other First Word is eliminated, you can use the formula: =REGEX.SUBSTITUTE(A1,"^(A|The)\s",,,,FALSE,TRUE) The Regular Expression "^(A|The)\s" is looking to match the pipe-separated list of phrases that are within the parentheses, and replace it with nothing. So you could, for example, expand it as desired: "^(A|The|An)\s" If you wanted to have a range that would dynamically sort, you could have a data entry column named "rng" where you just enter the film names sequentially. "rng" cannot refer to an entire column. In your display column, enter the formula: =INDEX(VSORT(rng,REGEX.SUBSTITUTE(rng,"^(A|The)\s" ,,,, FALSE,TRUE),1),ROWS($1:1)+COUNTBLANK(rng)) and copy/drag down. This column will display the entries in "rng" in sorted order. This formula will give a #REF! error if you have more formula rows than entries. This latter can be taken care of either in the formula itself, or by using conditional formatting to check for the #REF! error and change the font to the background color if it is present. The dynamically sorted solution can take a long time depending on how large "rng" is. --ron
| IP: Logged
|
|
Frank Cox
Film God
Posts: 2234
From: Melville Saskatchewan Canada
Registered: Apr 2011
|
posted 08-31-2011 12:51 AM
I know nothing at all about how Excel works, but I do know that OpenOffice and LibreOffice can open Excel spreadsheets.
I also know that you can set up custom sort lists and do sub-sorts from that with those programs.
Here is a short explanation of sorting using OpenOffice Calc (also applicable to LibreOffice). I'm not a spreadsheet power user of any kind, though, so I can't tell you much more about that other that referring you to the documentation.
Another solution would be export your data to a CSV file (I think Excel can do that, if not OO or LO can) and something like awk to sort the file. Awk can be pretty intimidating, though.
If it were me, since I'm not an awk expert, I would be inclined to go the CSV route and just write a little program that would do the following:
1. Read through the text file, move all THE and A to the end of the title, write result to a temp file (or hold it in ram, depending on the total size of the data in question). 2. Sort the temp file (or the array) using one of a variety of methods, again depending on how much data you're working with. 3. Write the sorted result to a new CSV file, which you can import back into Excel (via OO or LO if necessary).
Done.
If you have a Windows C compiler (or can get access to one) and provide me with the field descriptions you're using and number of lines, I could write a program to sort that for you pretty quickly. I don't have a Windows C compiler. I do have Turbo C for DOS but I'm not sure if DOS executables run on modern Windows versions any more.
| IP: Logged
|
|
Frank Cox
Film God
Posts: 2234
From: Melville Saskatchewan Canada
Registered: Apr 2011
|
posted 08-31-2011 03:19 AM
Please don't shoot me for writing a new post right under my previous one. I tried to edit it to add this but was told "Sorry the time limit for editing your post has expired" so I guess I have to create this new post instead.
It occurs to me that all you really need to do is move A and The to the back of the first field in your csv file. Since you already have a spreadsheet set up, you might as well let your spreadsheet program do the heavy lifting. So, move the movie title field to be the first column of your spreadsheet. Export your spreadsheet to a csv file.
Run this program after compiling it with any handy C compiler that works with your system. This is pretty generic ANSI C so it should compile on anything with a CPU and some ram:
quote: #include <stdio.h> #include <string.h> #include <stdlib.h>
int main(void) { char temp[1024]; int counter; FILE *fp,*output; if ((fp=fopen("abbott.csv","r"))==NULL) { printf("Can't open input file, aborting"); exit(1); } if ((output=fopen("costello.csv","w"))==NULL) { printf("Can't open output file, aborting"); exit(1); }
while (fgets(temp,1024,fp) != NULL) { if (!strncmp(temp,"The ",4)) { counter=4; while (temp[counter] != ',') { temp[counter-4]=temp[counter]; counter++; } temp[counter-4]=' '; temp[counter-3]='T'; temp[counter-2]='h'; temp[counter-1]='e'; } else if (!strncmp(temp,"A ",2)) { counter=2; while (temp[counter] != ',') { temp[counter-2]=temp[counter]; counter++; } temp[counter-2]=' '; temp[counter-1]='A'; } fprintf(output,"%s",temp); }
fclose(fp); fclose(output); return(0); }
The program looks for a file named abbott.csv and creates a new file named costello.csv. We assume that the maximum length of any single line of your spreadsheet is not more than 1023 characters; if it is greater than that, then change the number in the "char temp" declaration and the fgets to match or exceed the maximum number of characters in a single line, plus one.
We assume that the movie title field is the first column of your spreadsheet.
After running the program, import costello.csv back into your spreadsheet program. Now you can sort it to suit; all of the A the The are at the end of the movie titles and the rest of the columns are unchanged.
For the sake of simplicity I didn't put any punctuation before the A or The other than a single space. You can always do a search and replace on that column after you have it back in the spreadsheet to make it look like whatever you choose. Again, we're going to let the spreadsheet do the heavy lifting.
There is no particular limit to how many lines you can process with this program -- it just reads one line at a time and keeps going until it hits the end of the input file.
This program could obviously be beautified and bulletproofed quite a bit, but for a one-off job like what you're doing here, this will work. I just tried it here and there were no explosions, fires or earthquakes, so I guess it works. Note that this program comes with my standard two-part guarantee: If you break it, you get to keep both pieces.
| IP: Logged
|
|
Mark J. Marshall
Film God
Posts: 3188
From: New Castle, DE, USA
Registered: Aug 2002
|
posted 08-31-2011 04:38 AM
Assuming the movie titles are in column A, starting in row 2, put this in the second row of the column you want to make the new title and drag it down. (If it's in a different cell, just change the four "A2"s to whatever the first cell of movie titles is.)
=IF(LEFT(A2,4)="The ", CONCATENATE(RIGHT(A2, (LEN(A2)-4)), ", The"), A2)
To put that newly formatted column back in column A just highlight it and copy it, then "Paste Special" on column A and select "Values".
| IP: Logged
|
|
|
|
Frank Cox
Film God
Posts: 2234
From: Melville Saskatchewan Canada
Registered: Apr 2011
|
posted 08-31-2011 11:21 AM
Indeed, Chris, and that is exactly what that little program does.
Assuming input lines that look like this:
The Big Man, him, her A Large Pizza, me, you
The program will change those lines to look like this:
Big Man The, him, her Large Pizza A, me, you
After importing the csv file back into the spreadsheet you can add a comma before the The by doing a search-and-replace on " The" and replacing it with ", The" and the same with the A. I could have put that functionality into the little program, but why bother when he's just putting it back into a spreadsheet that can do that part for him anyway.
| IP: Logged
|
|
Mark J. Marshall
Film God
Posts: 3188
From: New Castle, DE, USA
Registered: Aug 2002
|
posted 08-31-2011 11:55 AM
I missed that you wanted to move "The" AND "A". This line will do both, and leave everything else alone.
=IF(LEFT(A2,4)="The ",CONCATENATE(RIGHT(A2,(LEN(A2)-4)),", The"),(IF(LEFT(A2,2)="A ",CONCATENATE(RIGHT(A2,(LEN(A2)-2)),", A"),A2)))
| IP: Logged
|
|
Frank Angel
Film God
Posts: 5305
From: Brooklyn NY USA
Registered: Dec 1999
|
posted 08-31-2011 03:29 PM
Damn Mark, you are good!
I am still muddlng along as a first-time user of Excel. For years I had been using a sweet little database program FileExpress which did EVERYTHING I ever wanted to keep trailers, 1sheets, prints nicely organized. No matter how you sorted things in FileExpress, every entry had a permanent RECORD number, so you could get everything back to the way it was entered. Imagine my surprise (and horror) when the first time I entered maybe 200 plus 1Sheet titles tried to arranged the NAME row in alphabetical order, that it didn't take all the other rows with it, essentially taking the information and shuffling it like a deck of cards....and screwing me.
Well, I could just put everything back in RECORD number, right? There were RECORD numbers in the very first column; I can sort on that. Not it Excel. No such use of record reference. And once columns are out of order and shuffled, they are OUT OF ORDER and never to be UNshuffled again.
Only then did I fully understand what that little dialogue box meant when it asked if I wanted to sort EVERY column or just the TITLE column that I was on. Silly me thought, "Well, no, I only want to alphabetize the one I have highlighted. Uh oh. This looks bad, What happened? Let me try to sort all of the columns." BAZOOM...ruination. Now nothing matched. Titles have lost their locations numbers and location numbers no longer matched their content number as well as all the other data. Better ask on Google about this. Google came up with plenty of answers, all of which in one form or another said stuff like "You're doomed, stupid."
It's back to FileExpress.
PS, In my defense, when software is going to make that kind of catastrophic change, USUALLY you expect it to be more alarmist, like "Pressing enter will PERMANENTLY loose the present relationship between the column you are sorting and the rest of the data. DO YOU WANT TO DO THIS?" MS is usually pretty good about its warnings. With Excel I think they were much too tame.
| IP: Logged
|
|
|
|
|
|
|
|
All times are Central (GMT -6:00)
|
This topic comprises 2 pages: 1 2
|
Powered by Infopop Corporation
UBB.classicTM
6.3.1.2
The Film-Tech Forums are designed for various members related to the cinema industry to express their opinions, viewpoints and testimonials on various products, services and events based upon speculation, personal knowledge and factual information through use, therefore all views represented here allow no liability upon the publishers of this web site and the owners of said views assume no liability for any ill will resulting from these postings. The posts made here are for educational as well as entertainment purposes and as such anyone viewing this portion of the website must accept these views as statements of the author of that opinion
and agrees to release the authors from any and all liability.
|