I'm extracting some data using imacros, and trying to append that data into a csv.
This is my code for extraction
'Gives me a numeric value(e.g 14)
TAG POS=1 TYPE=span ATTR=CLASS:proPriceField&&TXT:* EXTRACT=TXT
SET !EXTRACT EVAL("'{{!EXTRACT}}'.match(/[0-9,]+/);")
'Gives me a numeric value(e.g 2456)
TAG POS=1 TYPE=span ATTR=CLASS:sqrPriceField&&TXT:* EXTRACT=TXT
SET abc EVAL("'{{!EXTRACT}}'.match(/[0-9,]+/);")
'Gives me a text value(e.g "Kalyan")
TAG POS=1 TYPE=span ATTR=CLASS:localityFirst&&TXT:* EXTRACT=TXT
'Gives me lattiude from a link
TAG POS=2 TYPE=a ATTR=class:stop-propagation&&TXT:* EXTRACT=HTM
SET lat EVAL("'{{!EXTRACT}}'.match(/\?(lat=.+?)&/)[1];")
'Gives me longitude from a link
SET longt EVAL("var regex = /longt=(\\d+(?:\\.\\d+)?)/g; var str = '{{!EXTRACT}}';str.match(regex)[1];")
SAVEAS TYPE=!EXTRACT FOLDER=* FILE=temp.csv
This is the link from where I'm extracting data.
I'm expecting data should be appended in the following format
ProPrice SqrPrice Locality Lat Longt
14 2456 Kalyan 19.456 17.897
But the above code gives error "reject is not defined, line: 20 (Error code: -1001)" while writing data in csv, Any suggestion on why is it happening. Any help would be much appreciated.Thanks
I corrected your code a little:
'Gives me a numeric value(e.g 14)
TAG POS=1 TYPE=span ATTR=CLASS:proPriceField&&TXT:* EXTRACT=TXT
SET ProPrice EVAL("'{{!EXTRACT}}'.match(/[0-9,]+/);")
SET !EXTRACT NULL
'Gives me a numeric value(e.g 2456)
TAG POS=1 TYPE=span ATTR=CLASS:sqrPriceField&&TXT:* EXTRACT=TXT
SET SqrPrice EVAL("'{{!EXTRACT}}'.match(/[0-9,]+/);")
SET !EXTRACT NULL
'Gives me a text value(e.g "Kalyan")
TAG POS=1 TYPE=span ATTR=CLASS:localityFirst&&TXT:* EXTRACT=TXT
SET Locality {{!EXTRACT}}
SET !EXTRACT NULL
'Gives me lattiude from a link
TAG POS=2 TYPE=a ATTR=class:stop-propagation&&TXT:* EXTRACT=HTM
SET lat EVAL("'{{!EXTRACT}}'.match(/\?(lat=.+?)&/)[1];")
'Gives me longitude from a link
SET longt EVAL("var regex = /longt=(\\d+(?:\\.\\d+)?)/g; var str = '{{!EXTRACT}}';str.match(regex)[1];")
SET !EXTRACT {{ProPrice}}[EXTRACT]{{SqrPrice}}[EXTRACT]{{Locality}}[EXTRACT]{{lat}}[EXTRACT]{{longt}}
SAVEAS TYPE=EXTRACT FOLDER=* FILE=temp.csv
Related
I am trying to extract the date from a field based on a pattern - If the first four characters of the field description are *SLD then I need to extract the date from the field description as output date else I need to take the date from the field orddate as the the output date..please find the table below:
description
orddate
output Date
*SLD 5/18/22 Rimel
5/2/2022
5/18/2022
SOLD mila
5/3/2022
5/3/2022
*SLD 5/23/22 345671 kilo
5/15/2022
5/23/2022
*SLD 5/14/22 jing ming
5/1/2022
5/14/2022
123566
5/12/2022
5/12/2022
I would do something like:
Case
When Left(description,4) = '*SLD' Then
Replace( /*as months can have 1 or 2 digits, the resulting string could have some spaces that we need to clean*/
Left( /* Remove characters after the date */
Right(description, Len(description) - 5) /* Remove '*SLD ' */
,8
)
,' ',''
)
Else orddate
End
I am trying to extract the date from a field based on a pattern - If the first four characters of the field description are *SLD then I need to extract the date from the field description as output date else I need to take the date from the field orddate as the the output date..please find the table below:
description
orddate
output Date
*SLD 5/18/22 Rimel
5/2/2022
5/18/2022
SOLD mila
5/3/2022
5/3/2022
*SLD 5/23/22 345671 kilo
5/15/2022
5/23/2022
*SLD 5/14/22 jing ming
5/1/2022
5/14/2022
123566
5/12/2022
5/12/2022
The following Beast mode also contains the pattern SLD followed by the date with no space..
DATE(
CASE WHEN LEFT(`description`,5) = '*SLD ' THEN
IFNULL(TRY_CAST(SPLIT_PART(`description`,' ',2) AS DATE),`orddate`)
WHEN LEFT(`description`,4) = '*SLD' THEN
IFNULL(TRY_CAST(SPLIT_PART(REPLACE(`description`,'*SLD',''),' ',1) AS DATE),`orddate`)
ELSE
`orddate`
END)
Error:ERROR 3429: For 'isnull', types date and varchar are inconsistent
I am trying to calculate the total number of events that would occur based on the following known parameters
start date
end date
Days of the week
frequency of weeks (every week, every 2 weeks, etc)
For example, based on the following example data:
05/01/2017
05/31/2017
1,4 (Sunday, Wednesday)
Every 2 weeks
I would have to calculate that this event would run four times (5/7, 5/10, 5/21, 5/24)
Below is the skeleton I have set up. I'm fully stumped on how to increment the current day in the loop based on the number of weeks have passed.
<cfset local.totalRuns = 0 />
<cfset local.startDate = '2017-05-01' />
<cfset local.endDate = '2017-05-31' />
<cfset local.totalDays = DateDiff("d", local.startDate, local.endDate) />
<cfset local.daysPerWeek = '1,4' />
<cfset local.recurrence = 2 />
<cfset local.currentLoop = 0 />
<cfset local.weeksToCount = local.recurrence * 2 />
<!--- Loop a day at a time --->
<cfloop from="#local.startDate#" to="#local.endDate#" index="local.thisDay" step="#createTimespan(1, 0, 0, 0)#">
<cfset local.currentDate = local.thisDay />
<!--- Loop over each allowed day of the current week and determine actual date --->
<cfloop list="#local.daysPerWeek#" index="local.currentDay">
<!--- if current date does not exceed the end date add increment (this current is incorrect) --->
<cfif DateDiff("d", local.currentDate, local.endDate) LTE 0>
<cfset local.totalRuns++ />
</cfif>
</cfloop>
<cfset local.currentLoop++ />
</cfloop>
This is a formatted comment. It shows the approach I would take.
set the recurrence count to 0
start looping through the list of valid days of the week (1,4) in this case
set the control date to the start date.
do something to set the control date to the earliest
date that matches the day of the week in this loop.
if the control date is greater than the end date, break out of the loop.
otherwise
add 1 to the recurrence count
set up a while loop that adds the specified number of weeks
to the control date, and repeats the check I just described
end looping through the list of valid days of the week (1,4) in this case
My script is saving texts
set dataBackupFile to (path to desktop folder as text) & "Note_Backup.txt"
It's time I run the script, this added the date
set myDate to date string of (current date)
set myTime to time string of (current date)
set myDateTime to "--------------------------------------------------------------
" & myDate & " - " & myTime & "
Result :
Wednesday 9 November 2016 -
How can I get AppleScript to count how many time this date is listed on the text file, so I can added to the title
E.g :
Wednesday 9 November 2016 - (2)
My script :
set myDate to date string of (current date)
set filetocheck to (path to desktop folder as text) & "Note_Backup.txt"
set counter to (count text items of myDate) of filetocheck
But the result is 25, while the real result on the files is 38.
The text to count is in this format (Wednesday 9 November 2016):
Wednesday 9 November 2016 -- 10:10:54 - 1 (-41)
0000 other data here
You can do it with text item delimiters, replace linefeed with return if the line delimiter characters are \r
set {TID, text item delimiters} to {text item delimiters, "--" & linefeed & date string of (current date)}
set counter to (count text items of myDateTime) - 1
set text item delimiters to TID
counter will contain the number of occurrences
To check your text file use
set myDate to date string of (current date)
set filetocheck to (path to desktop folder as text) & "Note_Backup.txt"
set theText to read file filetocheck
set {TID, text item delimiters} to {text item delimiters, "--" & linefeed & date string of (current date)}
set counter to (count text items of theText) - 1
set text item delimiters to TID
Here's the problem, i need to create a date range on the variable below.
define variable s_date as character format "99/9999" no-undo.
There is a start_date column in my db (format "99/99/9999"(dd/mm/yyyy)) the date when a customer sales order was entered.
What i need to do is set the variable to create the date range, search and display the results of every sales order of the defined month and year.
PS: I 'm using a form , so the user can define the range of the month and year.
Here's something to get you started. You will have to look into converting it to fit your form.
If you're on an older release that haven't got the ADD-INTERVAL function you can use the DATE function and add +1 to the month instead (just remember that if the month is December (12) you're going to have to increase the year instead and set the month to 1).
DEFINE VARIABLE cFromDate AS CHARACTER NO-UNDO.
DEFINE VARIABLE dtFromDate AS DATE NO-UNDO LABEL "From".
DEFINE VARIABLE dtTomDate AS DATE NO-UNDO LABEL "Tom".
DEFINE VARIABLE iMonth AS INTEGER NO-UNDO.
DEFINE VARIABLE iYear AS INTEGER NO-UNDO.
UPDATE cFromDate FORMAT "99/9999" NO-ERROR.
IF LENGTH(cFromDate) <> 6 THEN DO:
MESSAGE "Invalid format" VIEW-AS ALERT-BOX ERROR.
RETURN ERROR.
END.
ASSIGN
iMonth = INTEGER(SUBSTRING(cFromDate,1,2))
iYear = INTEGER(SUBSTRING(cFromDate,3,4)) NO-ERROR.
IF iMonth < 1 OR iMonth > 12 THEN DO:
MESSAGE "Invalid month" VIEW-AS ALERT-BOX ERROR.
RETURN ERROR.
END.
IF iYear < 1990 OR iYear > 2020 THEN DO:
MESSAGE "Invalid year" VIEW-AS ALERT-BOX ERROR.
RETURN ERROR.
END.
ASSIGN
dtFromDate = DATE(iMonth, 1, iYear)
dtTomDate = ADD-INTERVAL(dtFromDate, 1, "month") - 1.
DISPLAY
dtFromDate FORMAT "9999-99-99"
dtTomDate FORMAT "9999-99-99".