Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

dumping a field from all records in a category to a text file

Quote Reply
dumping a field from all records in a category to a text file
Hi, I have a set of records under a category where I want to dump a RECORD ID field (unique ID, not LINK ID) & the Name field to a text file - one per line (the 2 fields separated by commas) so I can go on to further email this list out. Also I wanted to have a single line that has the subcategory from which the records were dumped as the top-level category is traversed.

Does anybody know if LSQL has a built-in function that does 75% of this or how a global might be written to do this? Seems pretty easy actually!
Quote Reply
Re: [scorpioncapital] dumping a field from all records in a category to a text file In reply to
Could use a simple script...

Code:
#!/usr/bin/perl

use strict;

use lib 'path/to/admin';
use Links qw/$IN $DB $CFG/;
Links::init('/path/to/admin');
open (WRITE, ">export.txt") || die $!;

my $sth = $DB->table('Links')->select();
while (my $hit = $sth->fetchrow_hashref) {
print WRITE "$hit->{field1},$hit->{field2}\n";
}
close (WRITE);

Change the bits in red to save the field names you want :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] dumping a field from all records in a category to a text file In reply to
awesome Andy, thanks alot!
Quote Reply
Re: [Andy] dumping a field from all records in a category to a text file In reply to
Is there a way to specify the category to export?