Author Archives: Aron

PowerShell – Count number of commas in each row of a CSV

So sometimes your data is so bad that you can’t trust a two column CSV to be turned into a dictionary, or more aptly, the file that is supposed to be two columns won’t open with in python to convert it to a dictionary because it doesn’t see two columns. So where is the issue? Probably a column count, which you can usually figure out if there are extra in excel but what if there are less? This PS snippet will read a given CSV, count the number of columns in the header row and report on any difference in the file, assuming your header row is correct this tells you which lines aren’t helping to validate a file.

$data = Get-Content location.csv

#Count in header
$header = $data[0].Split(",").Count
#Line counter
$i = 1

#Find lines with less or more commas
$data | ForEach-Object { 
    $c = $_.Split(",").Count
    if($c -ne $header) { "Line $i - $c commas" }
    $i++
}

Python – FutureWarning

Being new to python and running it in the Jupyter notebooks, sometimes you get errors that just don’t make sense and it’s a bit frustrating when you can’t make sense of the error. Let’s take this gem:

/home/aron/anaconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3397: FutureWarning: In a future version of pandas all arguments of read_csv except for the argument 'filepath_or_buffer' will be keyword-only.
  exec(code_obj, self.user_global_ns, self.user_ns)

So what the hell does that mean? I understand pandas, arguments, and what read_csv is but what is keyword-only???

It turns out that this keyword only means that instead of relying on the order of the argument, you simply need to use the keyword for anything except for filepath or buffer…

So this piece of code throws the error:

# Load in the general demographics data.
azdias = pd.read_csv('Udacity_AZDIAS_Subset.csv', ';')

And this is the error fixed:

# Load in the general demographics data.
azdias = pd.read_csv('Udacity_AZDIAS_Subset.csv', delimiter=';')

Python – Dataframe – Unique Value in Column

This is the select distinct to get the individual values of a column:

dataFrame.column.unique()

Mute/Unmute System Volume

I work from home, so I have an office (room set aside as one) and I try to keep office hours but one of the things that no matter how hard I try, I fail to turn the volume on in the morning so I get notifications for meetings, email and IM’s and turn it off when leaving so I’m not hearing the notification for meetings, email and IM’s. You’d think this is fairly simple, you’d be thinking wrong.
I found a way to pass the pressing of the mute button and was able to schedule it for 8 am and 5 pm. Not elegant because if the mute is on at 5 pm it gets un-muted. It’ll work for now until I can look deeper into it.

Create a batch file that you’ll call with task scheduler. It’s one line:

powershell (new-object -com wscript.shell).SendKeys([char]173)

Command-Line in Current Directory

My friend and work cohort David Miller keyed me into this last year and it’s been one of the most helpful tips I’ve gotten in years. Need to drop to a command line for the directory you’re currently browsing in Windows explorer? Simply type in cmd in the address bar and you’ve got a command window homed to that directory!!!

TCC 22a.1 – Issues With TCC_Touchpoints

So they’ve upgraded saxon8.jar to saxon10.jar (the XSLT and XQuery processor) but the framework (TCC_Touchpoints) that the majority of installs use have the reference to saxon8.jar hardcoded in the init.bat/.sh files. Not sure that hard coded is the right word as you can change it but it’s another thing that would have been nice to know.

So the quick takeaway is that if you are using TCC_Touchpoints at all in your integrations, a change is going to have to be made to the touchpoints itself before it can work at all with TCC 22a.1. Initial testing with this fixed allows for a successful run but it no longer displays the workflow progress of the job.

TCC 22a.1 – Released! And it’s broke…

So it seems that Oracle has release the much awaited TCC 22a.1 to fix the log4j issue. But it seems to have an issue when the TaleoConnectClient.bat is called which is the case for every scheduled integration. Someplace there is a call to saxon8.jar when this release ships with saxon10.jar. While you’ll be able to run the integration in the GUI, once you try to run a CLI job you’ll get something like this:

C:\onedrive_tt\Client\TCC_Touchpoints\bin\Windows>test22-candidateExport.bat > batchRun.txt
Error: Unable to access jarfile C:\TCC\TaleoConnectClient22a1\lib\saxon8.jar
Error: Unable to access jarfile C:\TCC\TaleoConnectClient22a1\lib\saxon8.jar
Error: Unable to access jarfile C:\TCC\TaleoConnectClient22a1\lib\saxon8.jar
Error: Unable to access jarfile C:\TCC\TaleoConnectClient22a1\lib\saxon8.jar
Error: Unable to access jarfile C:\TCC\TaleoConnectClient22a1\lib\saxon8.jar
Error: Unable to access jarfile C:\TCC\TaleoConnectClient22a1\lib\saxon8.jar
Error: Unable to access jarfile C:\TCC\TaleoConnectClient22a1\lib\saxon8.jar

C:\onedrive_tt\Client\TCC_Touchpoints\bin\Windows>CLS
### ERROR - The default endpoint must be defined with a vaild host. ###
Press any key to continue . . . 

Issue was found the issue last week on 4/7, will try to get a case open on it. In any case a work around is to actually put the saxon8.jar in the lib so it will run but it won’t log or return anything so you have to check the profiler.

TCC – Custom Steps

In normal circumstances, I’d just give a link to where these files live but from the best I can tell their home on the web has been removed. So given that they were released under open source, I’ll provide the files in that spirit as I’m not sure where else they exist.

TCC – Emailing Import Errors

This is for when you need to have the results file sent to you if there are errors in said results file. This can be a little tricky because you will not get a file if all elements were successful although you can probably do something about that with the trigger rule.
In any case this is the last custom step of the post process and assuming you have the mail host set properly in the config boards, you should be golden.

<cli:CustomStep>
	<cli:JavaClass>com.taleo.integration.client.customstep.mail.SendEmailPostStep</cli:JavaClass>
	<cli:Parameters>
		<cli:Parameter>
			<cli:Name>active</cli:Name>
			<cli:Value>true</cli:Value>
		</cli:Parameter>
		<cli:Parameter>
			<cli:Name>SMTPHost</cli:Name>
			<cli:Value>[MAIL_HOST]</cli:Value>
		</cli:Parameter>
		<cli:Parameter>
			<cli:Name>from</cli:Name>
			<cli:Value>[ALERTING_MAIL_FROM]</cli:Value>
		</cli:Parameter>
		<cli:Parameter>
			<cli:Name>to</cli:Name>
			<cli:Value>[ALERTING_MAIL_ON_ERROR_TO]</cli:Value>
		</cli:Parameter>
		<cli:Parameter>
			<cli:Name>subject</cli:Name>
			<cli:Value>Reporting - Subject/Object of Integration</cli:Value>
		</cli:Parameter>
		<cli:Parameter>
			<cli:Name>messageTemplate</cli:Name>
			<cli:Value>$file.content()</cli:Value>
		</cli:Parameter>
		<cli:Parameter>
			<cli:Name>sendAttachment</cli:Name>
			<cli:Value>true</cli:Value>
		</cli:Parameter>
		<cli:Parameter>
			<cli:Name>triggeringRule</cli:Name>
			<cli:Value>$logic.greaterThan($file.errorCount(),0)</cli:Value>
		</cli:Parameter>
	</cli:Parameters>
</cli:CustomStep>

Python and Pandas on Jupyter

Maybe it should be in Jupyter??? In any case, I’ve been studying using python in jupyter notebooks and it’s some pretty radical stuff. Using numpy and %matplotlib inline can yield some incredible results. This is a list of the commonly used features and samples thereof.

read more »