Read-Text-File-Online

Fri 14 November 2025

title: "Read Text File Online" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import urllib.request, json 
data = None
with urllib.request.urlopen("https://gitlab.com/rajacsp/datasets/raw/master/gandhi.txt") as url:
    data = url.read().decode()
data
'Mahatma Gandhi has been variously described as an …

Category: basics

Read More

Read-With-Unicode-Escape

Fri 14 November 2025

title: "Read Online CSV with Unicode Escape" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


'''
https://stackoverflow.com/questions/22216076/unicodedecodeerror-utf8-codec-cant-decode-byte-0xa5-in-position-0-invalid-s
'''
'\nhttps://stackoverflow.com/questions/22216076/unicodedecodeerror-utf8-codec-cant-decode-byte-0xa5-in-position-0-invalid-s\n'
from io import BytesIO
import requests
import pandas as pd
filename = 'https://www.sample-videos.com/csv/Sample-Spreadsheet-10-rows.csv'

r …

Category: basics

Read More

Recursion

Fri 14 November 2025

import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: ml311; pyv: 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0]'
print(pyu.ps2("haystack-ai ollama-haystack python-dotenv"))
haystack-ai==2.8.0
ollama-haystack is not installed in the current environment.
python-dotenv==0.21.0

import sys
print(sys …

Category: sys

Read More

Reduce

Fri 14 November 2025

title: "Reduce" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


from functools import reduce
def add(a, b): 
    return a + b
add(10, 15)
25
reduce(add, [10, 20, 30, 40])
100


Score: 5

Category: basics

Read More

Reduce-Advanced

Fri 14 November 2025

title: "Reduce Advanced" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


from functools import reduce
def do_magic(a, b): 

    if((a % 2 == 1) & (b % 2 == 1) ):
        return a * b

    return a + b
do_magic(10, 15)
25
do_magic(11, 15)
165
reduce(do_magic, [10, 20, 30, 40])
100 …

Category: basics

Read More

Reducer

Fri 14 November 2025

title: "Reducers" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import functools as fnt
list = [10, 40, 20, 50, 30, 90]
list
[10, 40, 20, 50, 30, 90]
sum_list = fnt.reduce(lambda x, y: x+y, list)
sum_list
240
def get_sum(list):
    return fnt.reduce(lambda x,y : x …

Category: basics

Read More

Regex-Groups

Fri 14 November 2025

title: "Regex Groups" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


import re
names = ['A2B8']

for name in names:
    m = re.match("^[A-Z]\d[A-Z]\d", name)

    if(m):
        print(m.groups())
        print('matched : ', name)
()
matched :  A2B8


Score: 0

Category: regex

Read More

Regexp-Stemmer

Fri 14 November 2025

title: "Regexp Stemmer" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


from nltk.stem import RegexpStemmer
re_stemmer = RegexpStemmer("ing$|s$|e$|able$", min=7)
words = [
    "wheels",
    "breaking",
    "thrones",
    "breakable"
]
words
['wheels', 'breaking', 'thrones', 'breakable']
result = [re_stemmer.stem(word) for word in words]
result
['wheels', 'break', 'throne', 'break']

As the …

Category: textprocessing

Read More

Remove Item On Loop

Fri 14 November 2025

title: "Remove Item on Loop" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


list = [
    1, 2, 3, 4, 5, 6
]
# remove even entries while looping
for i, j in enumerate(list):
    print(i, j)
0 1
1 2
2 3
3 4
4 5
5 6
for …

Category: basics

Read More

Remove Numbers

Fri 14 November 2025

title: "Remove Numbers" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false




Score: 0

Category: basics

Read More
Page 125 of 146

« Prev Next »