Is it possible to, when I save the extracted values in a csv file, add a Header or something in the first row of each column, so it's easier to know what the values refer to?
Thanks!
before beginning to extract with your main macro prepare your file with another one:
macro1 = "CODE:";
macro1 += "SET !EXTRACT First<SP>Header,<SP>Second<SP>Header" + "\n";
macro1 += "SAVEAS TYPE=EXTRACT FOLDER=U:\imacros FILE=test.csv" + "\n";
ret = iimPlay(macro1);
I just came upon this page looking for an answer to the same question. I found that I was able to get symbiotech's answer to work if I separated the headers with [EXTRACT] rather than with commas.
macro1 = "CODE:";
macro1 += "SET !EXTRACT First<SP>Header[EXTRACT]Second<SP>Header" + "\n";
macro1 += "SAVEAS TYPE=EXTRACT FOLDER=U:\imacros FILE=test.csv" + "\n";
ret = iimPlay(macro1);
Related
I am new to SSIS, I have created a data flow with oledb source and flat file destination.
Initially the destination file have row delimiter as {LF}
but I have to change it as {CR}{LF} now. I have around more than 100 flat file destinations like this.
I tried the following approaches, the second one works but it is time consuming process.
I tried by opening each flat file connection manager and try to change the row delimiter but my visual studio is not responding. I did several times but no luck.
I deleted the flat file connection manager and re-create it with right row delimiter then its working fine but my concern is I have to do it for more than 100 times.
I opened the .dtsx file in a text editor and I can find header row delimiter but unable to find row delimiter.
I try to change the row delimiter in the expression but it does not take into effect.
Is there any best way we can simply do this?
I used this to remove CRLF
"$text = [IO.File]::ReadAllText(" + #ic + #FullFilePath + #ic + ") -replace " +
ic2 +"`r`n" + #ic2 + "," + #ic2 +" " + #ic2 + "; [IO.File]::WriteAllText(" +
#ic+ #FullFilePath + #ic + ", $text)"
where
#ic = '
#ic2 = """
#FullFilePath is the path returned from the For..Loop container.
Note: I copy the original file to a new folder and update the copy rather than modify the original.
I expect this would work for you if you change this code:
-replace " + ic2 +"`r`n" + #ic2 + "," + #ic2 +" " + #ic2 + "
to
-replace " + ic2 +"`n" + #ic2 + "," + #ic2 +"`r`n" + #ic2 + "
I developed this in VS 2008.
screenshot
i've been trying to make this script work , but i just can't figure it out ! I would appreciate if somebody could help me.
So I'll start explaining:
-I have a list of email addresses in a text file , i know imacros only supports csv so what i do is :
At the end of each line i replace "\n" with a "," and save it as a csv.
Then i try to paste 25 email addresses.
It works , i get the email addresses , but now im stuck here trying to paste the next 25 addresses.
Here is what i made :
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
'TAB CLOSEALLOTHERS
SET !DATASOURCE ppl.csv
'SET !LOOP 1
'SET !DATASOURCE_LINE {{!LOOP}}
FRAME F=3
TAG POS=1 TYPE=TEXTAREA FORM=ID:addmember ATTR=ID:add-members-textarea CONTENT={{!COL1}}<SP>{{!COL2}}<SP>{{!COL3}}<SP>{{!COL4}}<SP>{{!COL5}}<SP>{{!COL6}}<SP>{{!COL7}}<SP>{{!COL8}}<SP>{{!COL9}}<SP>{{!COL10}}<SP>{{!COL11}}<SP>{{!COL12}}<SP>{{!COL13}}<SP>{{!COL14}}<SP>{{!COL15}}<SP>{{!COL16}}<SP>{{!COL17}}<SP>{{!COL18}}<SP>{{!COL19}}<SP>{{!COL20}}<SP>{{!COL21}}<SP>{{!COL22}}<SP>{{!COL23}}<SP>{{!COL24}}<SP>{{!COL25}}
'TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:addmember ATTR=ID:add-members-add-button
So the whole idea is to get 25 email addresses , add them to a database , then start from number 26 and add other 25 until there is no more.
//I have used javascript code with imcaros. May be this helps.
macro += "TAB T=1" + "\\n";
macro += "SET !DATASOURCE 39.csv" + "\\n";
macro += "SET !DATASOURCE_LINE {{i}}" + "\\n";
macro += "ADD !EXTRACT {{!COL1}}"+ "\\n";
//here u can stop the macro.js file and start at any value for your use case
for(var i=1;i<50;i++){
iimSet("i",i);
iimPlay(macro);
}
I would like access to a hash table element created by a function without creating an intermediate variable.
Here's code to explain what I want to do:
Function bla($aParameter) {
$ret = #{}
for($i in XX) {
$ret.Add([int]$i, [string]$value)
}
$ret
}
$myVar = ""
$myVar += (bla $aParameter).1 + ","
I tried $myVar += ((bla $aParameter).1) + "," without much success.
You need to cast the result to string like this:
$myVar += [string]((bla $aParameter).1) + ","
Which is weird since I already cast the value of my HashTable to [string].
Problem
In Enterprise Architect 7.1.834 in the code generation templates it is possible to print all the parent packages that a class belongs to in the scope of the File template?
The reason this is needed is to generate multi-include guards compliant with my companies coding standard
What doesn't work
I have tried both:
%list="Namespace__Notes" #separator="-"%
and
%packageName%
The output of both only prints the top-level parent package (Package1) but I would like to see:
Package1-Package2-Package3
Has anyone found a way to do this?
Namepace__Notes
Namepace__Notes is a custom template with Namepace type, the contents are ar follows
%PI=""%
%packageName%
[Edit] Dirty Solution
My current (dirty) solution is to mangle the file-path. Am I missing something?
The code:
$l_backslash = %REPLACE("\z","z","")%
$filepath = %filePath%
$upper_filepath = %TO_UPPER($filepath)%
$upper_package_as_path = $l_backslash + %TO_UPPER(packageName)% + $l_backslash
$upper_package_base_len = %LENGTH(packageName)%
$package_path_pos = %FIND($upper_filepath,$upper_package_as_path)%
%if $package_path_pos != "-1" and $package_path_pos != "0"%
$upper_filepath = %MID($upper_filepath,$package_path_pos)%
%endIf%
$file_define = "_" + $upper_filepath + "__"
$file_define = %REPLACE($file_define,".","_")%
$file_define = %REPLACE($file_define,$l_backslash,"_")%
$file_define = %REPLACE($file_define,"/","_")%
$body += "/**************************************************************************//**"
$body += "\n * \file " + %fileName%
$body += "\n *"
$body += "\n * \brief " + %elemType% + " " + %className% + " header file"
$body += "\n *"
$body += "\n * \author " + %classAuthor ? value : "<unknown>"%
$body += "\n *"
$body += "\n *****************************************************************************/"
$body += "\n"
$body += "\n#ifndef " + $file_define
$body += "\n#define " + $file_define
$body += "\n"
%packagePath% gives you the dot-separated package hierarchy, while %classQualName% yields the ::-separated class hierarchy (for inner classes).
This is for the current version, I don't know whether these macros were present as far back as 7.1. You should seriously consider upgrading, as the current version is 9.3 and EA is backwards-compatible wrt project contents.
In EA 10 %packagePath% also gives only top level package in File template
[Edit] Another dirty and partial solution.
I'v made a new custom templates, Namespace__fullName:
$prevName = %list="Namespace__fullName"%
%if $prevName != ""%
%packageName%::$prevName
%else%
%packageName%
%endIf%
;
and Class__fullQualName:
%list="Namespace__fullName"%::%classQualName%
This will work in simple cases when the source file contains only 1 class (possibly with nested items) and, therefore, only 1 namespaces hierarchy.
Is there a way to extract HTML page title using Perl? I know it can be passed as a hidden variable during form submit and then retrieved in Perl that way but I was wondering if there is a way to do this without the submit?
Like, lets say i have an HTML page like this:
<html><head><title>TEST</title></head></html>
and then in Perl I want to do :
$q -> h1('something');
How can I replace 'something' dynamically with what is contained in <title> tags?
I would use pQuery. It works just like jQuery.
You can say:
use pQuery;
my $page = pQuery("http://google.com/");
my $title = $page->find('title');
say "The title is: ", $title->html;
Replacing stuff is similar:
$title->html('New Title');
say "The entirety of google.com with my new title is: ", $page->html;
You can pass an HTML string to the pQuery constructor, which it sounds like you want to do.
Finally, if you want to use arbitrary HTML as a "template", and then "refine" that with Perl commands, you want to use Template::Refine.
HTML::HeadParser does this for you.
It's not clear to me what you are asking. You seem to be talking about something that could run in the user's browser, or at least something that already has an html page loaded.
If that's not the case, the answer is URI::Title.
use strict;
use LWP::Simple;
my $url = 'http://www.google.com'|| die "Specify URL on the cmd line";
my $html = get ($url);
$html =~ m{<TITLE>(.*?)</TITLE>}gism;
print "$1\n";
The previous answer is wrong, if the HTML title tag is used more often then this can easily be overcome by checking to make sure that the title tag is valid (no tags in between).
my ($title) = $test_content =~ m/<title>([a-zA-Z\/][^>]+)<\/title>/si;
get the title name form the file.
my $spool = 0;
open my $fh, "<", $absPath or die $!;
#open ($fh, "<$tempfile" );
# wrtie the opening brace
print WFL "[";
while (<$fh>) {
# removes the new line from the line read
chomp;
# removes the leading and trailing spaces.
$_=~ s/^\s+|\s+$//g;
# case where the <title> and </title> occures in one line
# we print and exit in one instant
if (($_=~/$startstring/i)&&($_=~/$endstring/i)) {
print WFL "'";
my ($title) = $_=~ m/$startstring(.+)$endstring/si;
print WFL "$title";
print WFL "',";
last;
}
# case when the <title> is in one line and </title> is in other line
#starting <title> string is found in the line
elsif ($_=~/$startstring/i) {
print WFL "'";
# extract everything after <title> but nothing before <title>
my ($title) = $_=~ m/$startstring(.+)/si;
print WFL "$title";
$spool = 1;
}
# ending string </title> is found
elsif ($_=~/$endstring/i) {
# read everything before </title> and nothing above that
my ($title) = $_=~ m/(.+)$endstring/si;
print WFL " ";
print WFL "$title";
print WFL "',";
$spool = 0;
last;
}
# this will useful in reading all line between <title> and </title>
elsif ($spool == 1) {
print WFL " ";
print WFL "$_";
}
}
close $fh;
# end of getting the title name
If you just want to extract the page title you can use a regular expression. I believe that would be something like:
my ($title) = $html =~ m/<title>(.+)<\/title>/si;
where your HTML page is stored in the string $html. In si, the s stands for for single line mode (i.e., the dot also matches a newline) and i for ignore case.