SSIS Foreach loop adding extra date and extension to one file name - ssis

When my package runs the Foreach loop container to rename 4 excel files it adds the date to each files and then adds an extra date and extension to the 1 file in the folder.
Example: Contracts_010120.xlsx_010120.xlsx.
REPLACE( #[User::Copy_Temp_M_To_J] ,"_TEMP.xlsx", "")
+ "_"+Right("0"+ (DT_WSTR ,2) DATEPART("mm",GetDate()),2)
+ RIGHT("0" + (DT_WSTR,2)DATEPART("dd",GetDate()),2)
+ RIGHT("0" + (DT_WSTR,4)DATEPART("yyyy",GetDate()) ,2)
+ ".xlsx"
It's just doing it to one file in the folder.

Related

Missing file (net.xml) in Running Environment Flow

On tutorial 01 from flow:Tutorial 01.
I executed the code
flow_params = dict(
exp_tag='ring_example',
env_name=AccelEnv,
network=RingNetwork,
simulator='traci',
sim=sim_params,
env=env_params,
net=net_params,
veh=vehicles,
initial=initial_config,
tls=traffic_lights,
)
# number of time steps
flow_params['env'].horizon = 3000
exp = Experiment(flow_params)
# run the sumo simulation
_ = exp.run(1, convert_to_csv=True)
I got an error afterward, here is the error
Error during start: [Errno 2] No such file or directory: '.../kernel/network/debug/cfg/ring_example_20201208-1332481607405568.58399.net.xml' Retrying in 1 seconds...
How should it be generated or where can it be found?
This is an issue with my file naming conversion. Apparently, the command to be called in
subprocess.call(
[
'netconvert -c "' + self.net_path + self.cfgfn +
'" --output-file="' + self.cfg_path + self.netfn +
'" --no-internal-links="false"'
],
stdout=subprocess.DEVNULL,
shell=True)
requires no spacing. In my case, I have my folder named "Machine Learning."

Remote Desktop using VB from access

I have a table inside that table 3 Columns {USERNAME,PASSWORD,IP}
I want to use that data to remote anyPC inside my network instead open the remote desktop and enter the user,pass and ip .
I used that code but that makes me open the remote desktop for an IP , but the user and password doesn't insert well.
That is my VB code
Private Sub Toggle133_Click()
Shell ("cmdkey /generic:TERMSRV" + ip.Value() + "/user:fourtex\" + Text126.Value() + "/pass:" + Text109.Value() & "mstsc.exe /v " + ip.Value())
Shell ("mstsc.exe /v " + ip.Value())
End Sub

SSIS Filename variable with wildcards

I am looking at creating a SSIS package that copies the latest file from a specific directory. There are multiple files output to the directory each day and each gets date and time stamped in the file name
FLATFILE_20150909_130801.txt
FLATFILE_20150909_230508.txt
I am only interested in the latest file during the day. Which will always have the same prefix 23 . I’ve written the expression as
"\\\\DESTINATION\\FLATFILE"+ "_"+ (DT_STR,4,1252)DATEPART( "yyyy" , getdate() ) + RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) + RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , getdate() ), 2) + "_"+ "23"+ "****"+ ".sqb"
Which returns FLATFILE_20150909_23****.txt
Is there any way to assign wildcards to the characters in the string **** so it ignores these??

subprocess.popen returning empty string

There was an earlier question on this, but the asker was just overwriting their output and solved their own problem.
I'm using a subprocess.popen to read video information and write the output to a json. It works fine on MOST videos, but on others is returning an empty string on others - even though it runs fine from the command line. I tried it several times and am getting the data fine through the command line.
Here's the relevant part of the script:
out_prj.write('[')
for m, i in enumerate(files):
print i
out_prj.write('{"$type":"BatchProcessor.Job, BatchProcessor","Id":0,"Ver":1.02,"CurrentTask":0,"IsSelected":true,"TaskList":[')
f_name = os.path.basename(i[0])
f_json = out_folder + os.sep + "06_Output" + os.sep + os.path.basename(i[0]).split(".")[0] + ".json"
trans_f = out_folder + os.sep + "04_Video" + os.sep + os.path.basename(i[0]).split(".")[0] + "-tr.ts"
trans_f_out = out_folder + os.sep + "06_Output" + os.sep + os.path.basename(i[0]).split(".")[0] + "-tr-out.ts"
ffprobe = 'ffprobe.exe'
command = [ffprobe, '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', i[0]]
p = sp.Popen(command, stdout=sp.PIPE, stderr=sp.PIPE, shell=True)
out, err = p.communicate()
io = cStringIO.StringIO(out)
info = json.load(io)
print info
filea = open(f_json, 'w')
filea.write(json.dumps(info))
filea.close()
f = open(f_json)
b = json.load(f)
print b
#########################
###################
f_format = str(b['streams'][0]['codec_long_name'])
Your code ignores error messages (err variable). print err or don't redirect stderr to see them.
Unrelated: the json handling in your code is insane: most operations are redundant.
To save output of the subprocess to a file:
import os
from subprocess import check_call
f_json = os.path.join(out_folder, "06_Output",
os.path.splitext(f_name)[0] + ".json")
with open(f_json, 'wb', 0) as file:
check_call(command, stdout=file)
Note: shell=True is not necessary here. If subprocess can't find ffprobe.exe then specify the full path e.g. (use the path appropriate for your system):
ffprobe = r'C:\Program Files\Real\RealPlayer\RPDS\Tools\ffmpeg\ffprobe.exe'
Note: r'' -- a raw string literal is used to avoid doubling the backslashes.

SSIS Derived Column Transformation

I am trying to develop a package which takes a string (in the format 1.02.3.04 or 01.02.03.4 and lots of other permutations) and amends this based upon the following rules
if the second character is a "." then pad the first group with a 0
FINDSTRING([mycolname],".",1) returns the position of the first "." and for all values of 2 then apply this rule and amend the string eg if 1.2.3.4 will return 2 the string should be 01.2.3.4
if the second instance of "." is 5 FINDSTRING([mycolname],".",2) then add a 0 in after the third character eg 01.02.3.4
if the third instance of "." is 8 FINDSTRING([mycolname],".",3) then add 0 in after the 6th character
I am a little stuck with some of the logic !
anyone help ??
in SSIS 2012 can be achieved with a one-liner Derived Column:
RIGHT("00" + TOKEN("1.02.3.04",".",1),2) + "." + RIGHT("00" + TOKEN("1.02.3.04",".",2),2) + "." + RIGHT("00" + TOKEN("1.02.3.04",".",3),2) + "." + RIGHT("00" + TOKEN("1.02.3.04",".",4),2)