[Solved] Selecting columns containing multiple keywords

Discuss the spreadsheet application
Post Reply
banathy
Posts: 4
Joined: Mon Jan 25, 2021 7:39 pm

[Solved] Selecting columns containing multiple keywords

Post by banathy »

Hi! Absolute beginner here... I have TONS of spredsheets containing metadata from tons of files, documents, images, videos, mp3s. Each sheet has hundreds of columns. I need only the columns containing FileName, FileSize, CreateDate, Resolution, FileType, PageCount, Bitrate and a few more.
I found a macro to delete specific columns, based on the column letter, but the problem is that in one sheet the FileName is in column B, in an other sheet it can be in D or Z or anywhere. Is there a macro or filter I can apply to keep only the columns containing specific text (FileName, FileSize, CreateDate, Resolution, FileType, PageCount, Bitrate), or to copy these columns to a new spreadsheet?
How would you aproach this? Thank you!
Last edited by Hagar Delest on Tue Jan 26, 2021 6:28 pm, edited 1 time in total.
Reason: tagged solved.
OpenOffice4.1, Windows 10
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Selecting columns containing multiple keywords

Post by RusselB »

Welcome to the Forums.
I'd start by using a better app, namely a database, rather than a spreadsheet.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
MrProgrammer
Moderator
Posts: 5283
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Selecting columns containing multiple keywords

Post by MrProgrammer »

Hi, and welcome to the forum.
banathy wrote:Absolute beginner here
[Tutorial] Ten concepts that every Calc user should know
banathy wrote:Is there a macro or filter I can apply to keep only the columns containing specific text (FileName, FileSize, CreateDate, Resolution, FileType, PageCount, Bitrate), or to copy these columns to a new spreadsheet?
You can copy them to a new sheet with a filter.
[Tutorial] Sorting and Filtering data with formulas
banathy wrote:I have TONS of [spreadsheets] containing metadata from tons of files, documents, images, videos, mp3s. Each sheet has hundreds of columns. … I need only the columns containing …
Did you type these megabytes of data yourself into Calc? If so, why did you enter a lot of data which you do not want?

Or was it actually imported into Calc from some external source? Which external source, very specifically? CSV files? Some damned Windows resource? Which resource, specifically? A database? Which database, specifically? Why do you not give us the full details about your problem?
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.6, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
banathy
Posts: 4
Joined: Mon Jan 25, 2021 7:39 pm

Re: Selecting columns containing multiple keywords

Post by banathy »

Thank you! :)
I have 4 TB worth of unsorted e-books, documents, images, videos, sound files in my university's library. Basically 20 years of bad data management. Now they want to catalogue all of them. Yesterday I managed to pull out all the metadata from every file from a single folder into a csv file. I had lots of csv files containing a lot of irrelevant tags in columns and I was trying to put all the columns I need into a single sheet and get rid of the rest. Today I figured it out how to pull out only the relevant metadata tags from the files and I generated new csv-s. Now I have to figure out, how to merge the csv files, and how to enter each file's filepath. I've never done anything of the sorts in my life, so I'm making it up as I go :D
OpenOffice4.1, Windows 10
jrkrideau
Volunteer
Posts: 3816
Joined: Sun Dec 30, 2007 10:00 pm
Location: Kingston Ontario Canada

Re: [Solved] Selecting columns containing multiple keywords

Post by jrkrideau »

Once you get a bit of the mess tidied up you really need to look into something like a data base or the same mess will happen again.
LibreOffice 7.3.7. 2; Ubuntu 22.04
User avatar
robleyd
Moderator
Posts: 5383
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: [Solved] Selecting columns containing multiple keywords

Post by robleyd »

how to merge the csv files
Make sure that the data structure of all the files you wish to combine is identical, otherwise you will have issues! Give all the files you wish to merge a common filename suffix, e.g. .csv and place them in the same directory. Navigate to that directory with file manager and open a command widow via right click. Then just issue the command

Code: Select all

copy *.csv merged.csv
If you need the ELI5 version of these instructions, with pictures, see https://www.wikihow.com/Merge-Text-(.Txt)-Files-in-Command-Prompt
You'll need to copy/paste the URL as the parentheses in it break the automatic link creation.
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 25.2.4.3; SlackBuild for 25.2.4 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue]
Unexpected '{' on line 32
.
banathy
Posts: 4
Joined: Mon Jan 25, 2021 7:39 pm

Re: [Solved] Selecting columns containing multiple keywords

Post by banathy »

Thank you so much, guys!
I'm almost done generating the csv-s for ALL folders. Hundreds and hundreds. Yeah, it is a nightmare. Exiftool doesn't likes folder names with spaces, so I have to rename them, run Exiftool then I have to revert to the original name. The csv file doesn't contain the full file path, just the (renamed) folder's name. So I will run find/replace to find the folder name and replace it with the full path. Afterwards I will try to merge the csv-s. Luckily the data structure is the same in all of them but my spider sense is tingling about the different special characters in the metadata. Hungarian, Turkish, Sanskrit... Oh well, we'll see.
My name is Attila and I will be an alcoholic.
OpenOffice4.1, Windows 10
User avatar
DiGro
Posts: 206
Joined: Mon Oct 08, 2007 1:31 am
Location: Hoorn NH, The Netherlands

Re: [Solved] Selecting columns containing multiple keywords

Post by DiGro »

I always liked working with Sam Francke's CSVed when dealing with *.csv

https://csved.sjfrancke.nl/index.html
____________
DiGro

AOO 4.1.15 (Dutch) on Windows 11. Scanned with Ziggo Safe Online (F-Secure)
Mountaineer
Posts: 335
Joined: Sun Sep 06, 2020 8:27 am

Re: [Solved] Selecting columns containing multiple keywords

Post by Mountaineer »

banathy wrote:Thank you so much, guys!
I'm almost done generating the csv-s for ALL folders. Hundreds and hundreds. Yeah, it is a nightmare. Exiftool doesn't likes folder names with spaces, so I have to rename them, run Exiftool then I have to revert to the original name. The csv file doesn't contain the full file path, just the (renamed) folder's name. ...
It may be to late for your case, but Exiftool accepts quoted filenames and in my case i used the recursive scan of all subfolders - no Problem with spaces here.
As I remember ther are names for filename and path, so your workaround shouldn't be necessary.

If you are interested I can find and post my script to access the collection of 80000 photos 4 photographers left behind in my archive at work...

J.
LibreOffice 7.6 on Windows 10pro and other Versions parallel
banathy
Posts: 4
Joined: Mon Jan 25, 2021 7:39 pm

Re: [Solved] Selecting columns containing multiple keywords

Post by banathy »

It may be to late for your case, but Exiftool accepts quoted filenames and in my case i used the recursive scan of all subfolders - no Problem with spaces here.
As I remember ther are names for filename and path, so your workaround shouldn't be necessary.

If you are interested I can find and post my script to access the collection of 80000 photos 4 photographers left behind in my archive at work...
Oh, it is definitely not to late, there are several other hard drives I haven't even touched yet... It would be amazing to see your solution. I started to suspect there may be a solution like this, but I never worked with spreadsheets or code or Exiftool before last week, all of this is pretty new to me.
OpenOffice4.1, Windows 10
Mountaineer
Posts: 335
Joined: Sun Sep 06, 2020 8:27 am

Re: [Solved] Selecting columns containing multiple keywords

Post by Mountaineer »

Code: Select all

@echo off
REM Extracts Exif-Tags for all Files in an Directory given as Argument to csv-File
REM !!  -r = recursive scan / omitt, if necessary

IF NOT EXIST P:\ExifTool\ GOTO NOPORT	
P:
cd p:\ExifTool\

Echo Scan of %1
exiftool.exe -r -csv -SourceFile -FileName -DateTimeOriginal -Model -ImageWidth -ImageHeight -Orientation -PhotometricInterpretation -Keywords %1 >%1\_EXIFData.csv
goto ENDE

:NOPORT
echo "Portable P:ExifTool missing"
goto :ENDE

:ENDE
pause
exit
This is a Windows-Batch. As I didn't installed exiftool for this, I mount my portable Tools at P: on Windows - Therfore the NOPORT-Part

Exiftool:
-r recursion
-csv output as csv file
SourceFile give the full path, filename only the name with extension
the other parameters select EXIF-Data I needed for this run

%1 >%1\_EXIFData.csv scans the given directory, output is directed to the named File in the directory; % is Windows Batch - adapt for bash

In a separate batch I collect/append all csv-Files and import them afterwards to a sqlite database.
It is also possible to register the resulting csv as Text-Database in AOO/LO-Base for direct access or simple queries,
but a real SQL-database is much more flexible and trustworthy.
(Edit: Early version to access csv as Text-Database from a german forum: https://www.libreoffice-forum.de/viewto ... XIF#p41302 )
J.
LibreOffice 7.6 on Windows 10pro and other Versions parallel
Post Reply