#!/usr/bin/perl # Copyright 22nd October 2008, Cotman University # http://www.cotmanuniversity.com # Created by Dr. Peter Kjeldsen # Department for Computational Linguistics # Conversion of Trados TM format to CSV format # File name: tracsv.pl # # Instructions # Change name of input file, source and target language # as required. # Run from command prompt perl tracsv.pl # # Opening input file open (TXT, "; close (TXT); # Looping through input file content line by line foreach $lines(@text) { # Splitting line content @line = split (/\>/, $lines); if ($line[0] eq '>src.txt") or die ("Cannot open file!"); $rawsource = chomp ($line[1]); $source = $line[1]; print SRC '"' . $source . '"' . "\n"; }; } # Closing output file close (SRC); # Looping through input file content line by line foreach $lines(@text) { # Splitting line content @line = split (/\>/, $lines); if ($line[0] eq '>tgt.txt") or die ("Cannot open file!"); $rawtarget = chomp ($line[1]); $target = $line[1]; print TGT '"' . $target . '"' . "\n"; }; } # Closing output file close (TGT); # Opening source input file open (SRC, ">tracsv.csv") or die ("Cannot open file!"); # Creating header for output file $header = '"Created by Lingualizer tmXl8tr","Created by Lingualizer tmXl8tr"' . "\n"; # Writing header in the output file print TM $header; # Looping through input file content line by line while ($line = ) { $line =~ s/\n//; print TM $line . $sep . } close (SRC); close (TGT); close (TM);