Found 26504 Articles for Server Side Programming

How to implement Concurrency with Threads in Python?

Kiran P
Updated on 09-Nov-2020 10:20:23

281 Views

IntroductionPython has different approaches like using threads, subprocesses, generators and other tricks for concurrent programming.Before we go on and implement threads, let us understand what exactly is concurrency.Concurrency is a piece of logic Within a single program that allows to open up many distinct paths of execution, including separate streams of I/O, running SQL queries, so on in a way that the execution seems to be both simultaneous and independent of each other.How to do it..First we create a single thread to go through the site urls and later look at how to use threading concepts to speed up the ... Read More

Program to convert each element in row and column to zero for zero values in Python

Arnab Chakraborty
Updated on 09-Nov-2020 10:28:02

522 Views

Suppose we have a 2D matrix of numbers, now for each zero in the given matrix and replace all values in its row and column with zero, and return the final matrix.So, if the input is like matrix, then the output will be matrix as the 0th, 2nd and 3rd rows contain 0 and the final matrix contains 0 in those rows. Similarly 0th, 1st and 2nd columns contain 0 and the final matrix contains 0 in those columns.To solve this, we will follow these steps:n := row count, m := column count res := make a matrix of size ... Read More

How to process excel files data in chunks with Python?

Kiran P
Updated on 09-Nov-2020 10:18:17

3K+ Views

IntroductionIt seems that the world is ruled by Excel. I've been surprised in my data engineering work to see how many of my colleagues are using Excel as a critical tool for making decisions. While I'm not a big fan of MS Office and their excel spread sheets, i will still show you a neat trick to handle large excel spread sheets effectively.How to do it..Before we jump into the program directly, let us understand few basics on dealing excel spreadsheets with Pandas.1. Installation. Go ahead and install openpyxl and xlwt. If you are unsure if it is installed or ... Read More

How to implement immutable Data structures in Python?

Kiran P
Updated on 09-Nov-2020 10:16:00

326 Views

ProblemYou need to implement immutable data structures in Python.Introduction..Immutable data structures are very handy when you want to prevent multiple people modifying a piece of data in parallel programming at same time. Mutable data structures( e.g. Array) can be changed at any time while immutable data structures cannot be.How to do it..Let me show you step by step how to deal with immutable and mutable data structures.Example# STEP 01 - Create a Mutable array. # Define an array atp_players = ['Murray', 'Nadal', 'Djokovic'] print(f" *** Original Data in my array is - {atp_players}")*** Original Data in my array is ... Read More

How to Compress files with ZIPFILE module in Python.

Kiran P
Updated on 09-Nov-2020 10:12:31

12K+ Views

ProblemYou want to create a compress files in python.IntroductionZIP files can hold the compressed contents of many other files. Compressing a file reduces its size on disk, which is useful when transferring it over the internet or between the systems using Control-m AFT or Connect direct or even scp.Python programs creates ZIP files using functions in the zipfile module.How to do it...1. We will be using zipfile and io packages. Install them with pip if any of the packages are missing on your system. If you are unsure, use pip freeze command to validate the packages.2. We will write a ... Read More

How to append new rows to DataFrame using a Template In Python Pandas

Kiran P
Updated on 09-Nov-2020 10:07:27

683 Views

How to append new rows to DataFrame using a Template In Python Pandas.IntroductionBeing a data engineering specialist, i often end up creating more derived columns than rows as the role of creating and sending the data to me for analysis should be taken care of other database specialists. However, it is not true during all time.We have to create sample rows rather than waiting for data specialists team to send us the data. In this topic i will be showing the neat tricks for creating rows.How to do it..In this recipe, we will begin by appending rows to a small ... Read More

How to Parse HTML pages to fetch HTML tables with Python?

Kiran P
Updated on 09-Nov-2020 10:04:02

829 Views

ProblemYou need to extract the HTML tables from a web page.IntroductionThe internet, and the World Wide Web (WWW), is the most prominent source of information today. There is so much information out there, it is just very hard to choose the content from so many options. Most of that information is retrievable through HTTP.But we can also perform these operations programmatically to retrieve and process information automatically.Python allows us to do this using its standard library an HTTP client, but the requests module helps in obtaining web pages information very easy.In this post, we will see how to parse through ... Read More

How to resize an Image C#?

Nizamuddin Siddiqui
Updated on 07-Nov-2020 12:14:52

585 Views

A bitmap consists of the pixel data for a graphics image and its attributes. There are many standard formats for saving a bitmap to a file. GDI+ supports the following file formats: BMP, GIF, EXIF, JPG, PNG and TIFF. You can create images from files, streams, and other sources by using one of the Bitmap constructors and save them to a stream or to the file system with the Save method.In the below code CompressAndSaveImageAsync Method Compresses the images and saves in the path Mentioned.The new image name will be a combination of desktop userId and dateTimeExampleprivate async Task CompressAndSaveImageAsync(Bitmap ... Read More

How can I limit Parallel.ForEach in C#?

Nizamuddin Siddiqui
Updated on 07-Nov-2020 12:12:44

2K+ Views

Parallel ForeachParallel.ForEach loop in C# runs upon multiple threads and processing takes place in a parallel way. Parallel.ForEach loop is not a basic feature of C# and it is available from C# 4.0 and above To use Parallel.ForEach loop we need to import System.Threading.Tasks namespace in using directive.ForeachForeach loop in C# runs upon a single thread and processing takes place sequentially one by one. Foreach loop is a basic feature of C# and it is available from C# 1.0. Its execution is slower than the Parallel.Foreach in most of the cases.Example 1static void Main(string[] args){    List alphabets = new ... Read More

How to determine if C# .NET Core is installed?

Nizamuddin Siddiqui
Updated on 07-Nov-2020 12:22:15

3K+ Views

The following options are for dotnet by itself. For example, dotnet −−info. They print out information about the environment if not installed it will throw error.−−infoPrints out detailed information about a .NET Core installation and the machine environment, such as the current operating system, and commit SHA of the .NET Core version.−−versionPrints out the version of the .NET Core SDK in use.−−list−runtimesPrints out a list of the installed .NET Core runtimes. An x86 version of the SDK lists only x86 runtimes, and an x64 version of the SDK lists only x64 runtimes.−−list−−sdksPrints out a list of the installed .NET Core ... Read More

Advertisements