Skip to content

Instantly share code, notes, and snippets.

source /home/ali/.sdkman/bin/sdkman-init.fis
#!/usr/bin/env fish
#
# Copyright 2017 Marco Vermeulen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@alialrahahleh
alialrahahleh / xml2csv.pl
Created July 26, 2019 06:11
Perl one liner to transform xml to csv
cat sample.xml | perl -F'[>|<]' -E 'say join(",", @list) and @list = () if $F[1] =~ "/ITEM"; push(@list, $F[2]) if length($F[2])
@alialrahahleh
alialrahahleh / csvtoxml.d
Last active July 26, 2019 02:49
usage $rdmd csvtoxml.d
import std.algorithm, std.stdio, std.string;
import std.regex;
import std.file;
import std.conv;
import std.typecons : Flag, Yes, No;
import std.mmfile;
import std.range: SortedRange;
import std.getopt;
import core.stdc.stdlib: exit;
@alialrahahleh
alialrahahleh / xml2cvs.clj
Last active July 17, 2019 02:44
XML to CSV sample code
ns st.core
(:gen-class))
(def init-state {:matching-enabled false
:p-headers true
:headers []
:values []})
(defn print-line [obj]
(when (obj :p-headers) (println (clojure.string/join "," (obj :headers))))
@alialrahahleh
alialrahahleh / sample.csv
Created July 16, 2019 06:40
sample csv output
ITEM-TYPE ORDER-ID ITEM-CODE TRANSACTION-DATE CUSTOMER-LOCATION ORDERED-BY ORDER-DATE
Car 3190996 15 222 USA Customer2 20161207111400
@alialrahahleh
alialrahahleh / sample.xml
Created July 16, 2019 06:34
Sample XML input
<ITEM>
<ITEM-CODE>15</ITEM-CODE>
<TRANSACTION-DATE>222</TRANSACTION-DATE>
<ITEM-TYPE>Car</ITEM-TYPE>
<ORDERED-BY>Customer2</ORDERED-BY>
<ORDER-DATE>20161207111400</ORDER-DATE>
<ORDER-ID>3190996</ORDER-ID>
<CUSTOMER-LOCATION>USA</CUSTOMER-LOCATION>
</ITEM>
@alialrahahleh
alialrahahleh / xml2csv.awk
Last active July 15, 2019 17:29
XML2CSV awk programin, usage: awk -vwth="ELEMENT-TO-CAPTURE" -vsp="," -f xml2cvs.awk XML-FILE-NAME
#Copyright 2019 Ali Mousa
#
#Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
#1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
#2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
#3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#