Skip to main content


Showing posts from December, 2020

Working with Lists in Python

Lists in Python Like an array, List is a collection of data (of different data types). Lists are specified using square brackets.  Lists are very helpful when working with data in Python. Below are some of the features of Lists.  Lists can hold data of different data types.  Lists can be amended. Data in the list can be accessed by using index. Lists can hold duplicate data.  In this post, we will see how to access, append or remove the data in Lists and how to use different list methods.  Creating List in Python Before we go on to different methods of lists, Let us see How to create a List in Python ? Like any other variable in python, List is created when the data is assigned with in square brackets.  In the above example, 'a_list' is created with the data and 'b_list' is created with no data.  Accessing the data in a List How to access the individual elements of Lists? Elements in the Lists can be accessed using index. Index starts with '0' and incremented by

Create/Write Data to IFS file from SQL - IBM i

IFS Stream File IFS (Integrated File System) stream files are major part of any (or most of) IBM i applications.  There are various ways to create stream files like CPYFRMIMPF, CPYFRMSTMF, EDTF... Creating the IFS file and writing the data has been made much easier with SQL procedure IFS_WRITE (IFS_WRITE_BINARY for writing the data in Binary format and IFS_WRITE_UTF8 for writing the data in UTF8 format).  In this post, we will see how to write the data into Stream file directly from SQL using IFS_WRITE procedure.  E.g.:  To start with, What we need is 'Path Name (IFS Directory & File Name)' and 'Data to be written'.  First parameter 'PATH_NAME' accepts the IFS path name along with the file name. In this example, '/home/REDDYP' is the directory and 'NewTextFile.txt' is the file name.  Directory should be present by the time the procedure is called. If not, Procedure call would be failed.  File name doesn't necessarily need to be present. I

Read data in IFS file from SQL - IBM i

IFS Stream File IFS (Integrated File System) Stream files are major part of any (or most of) IBM i applications. Having to read data from the Stream files become necessary.  We can read the IFS file from Programs in two different ways.  By copying the data from IFS file to Database file (CPYFRMSTMF or CPYFRMIMPF). By using 'open' & 'read' procedures written in 'C' language. Click Here to see more about how to read IFS file using these procedures from RPGLE. One other way to do this is by using SQL table function 'IFS_READ'. There are couple of more table functions 'IFS_READ_BINARY' and 'IFS_READ_UTF8' to read the data and return in Binary and UTF8 formats accordingly.  In this post, we will see how to read IFS file using 'IFS_READ' and little about the other two table functions towards the end. E.g.:  Above query is simple and straight forward, All we need to do is pass the required file name (along with full path) against pa

Operators in Python

Operators Operator is a symbol that is used to perform specific operations like mathematical, relational or logical operations.  There are different types of operators. Below are some the most common operators Mathematical Operators. Assignment Operators. Relational Operators. Logical Operators. Apart from these, there are couple of more types.  Identity Operators. Membership Operators. Let's have a look at each of these.  Mathematical Operators Mathematical operators are used to perform mathematical operations (as name states) with numeric values.  These are operators like '+' Addition, '-' Subtraction, '*' Multiplication, '/' Division, '%' Modulus, '//' Floor Division and '**' Exponentiation. a = 10 b = 5 c = a + b  # Addition of two variables, Result would be c = 15 c = a - b  # Subtraction of second variable from first variable,  Result would be c = 5 c = a * b  # Multiplication of two variables, Result would be c = 50 c =

Retrieve Objects present in IFS Directory from SQL - IBM i

Objects in IFS Directory Working with IFS (Integrated File System) is essential and almost part of day to day work for most of the IBM i developers.   In my experience below are the couple tasks I had to do frequently.  Check if an object is present in IFS directory.  Retrieve list of objects present in IFS directory.  This has been made easier to do these now (and much more) from SQL directly with 'IFS_OBJECT_STATISTICS' table function.  What does IFS_OBJECT_STATISTICS table function return ? It returns the attributes of an IFS Object for every object (including directory) present in the IFS Path provided.  Let's now have a look at how to retrieve the objects present for a specified path.  In the above query, Line - 1: Column 'PATH_NAME' returns the IFS Path (or Object) the row is returned for.  Line - 2: Column 'OBJECT_TYPE' returns the type of object retrieved.  Line - 3: Column 'CREATE_TIMESTAMP' returns the timestamp when the object was created.