Questions tagged [converting]

Converting involves changing data from one data type or format to another.

Filter by
Sorted by
Tagged with
2 votes
1 answer
69 views

PHP Parser and converter - SOLID and DRY

I am working on a PHP application that transforms data from the input CSV (JSON, TXT, or XML) into an output CSV (JSON or database, for example). The output format differs from the input: some columns ...
dev-chicco's user avatar
-4 votes
0 answers
29 views

ffmpeg crashes on my new i9-14900K with Segmentation fault error message [closed]

ffmpeg crashes on my new i9-14900K / Ubuntu 22.04.4 with Segmentation fault error message. Even after recompiling it specifically for my platform, it still crashes. Here is the whole output: ...
Keer's user avatar
  • 1
8 votes
1 answer
640 views

library for converting numbers to HEX

This is library for fast converting "HEX strings" to unsigned numbers and vice versa. The result is not defined, if input is incorrect, e.g. string "ZZZ1" will be converted to ...
Nick's user avatar
  • 1,572
2 votes
1 answer
52 views

How better methods of remaking the code by array without changing its functionality, and performance but reducing amount by ~10 times

Can anybody help me with examples of code? How is the approach to optimize code relative to my example with using "switch case" to "arrays"? Without changing its functionality, but ...
Vladistone's user avatar
0 votes
1 answer
233 views

WordPress Plugin for WebP/AVIF Image Conversion

I'm looking for feedback on a WordPress plugin I developed for automatically converting images to WebP and AVIF formats. The goal is to optimize image loading performance. The plugin has the following ...
KermitTheFrog's user avatar
1 vote
1 answer
75 views

safe numeric type converter

I have written a function for casting between built in numeric types. I built it to check if the source value is within the range of the destination value, and to provide a nicely legible error if not....
Diederick C. Niehorster's user avatar
1 vote
1 answer
185 views

C++ arbitrary base convertor

This is my second C++ program. Again, I wrote it all by myself. I only started learning C++ yesterday. The concept of the program is simple; it should read input from ...
Ξένη Γήινος's user avatar
4 votes
2 answers
371 views

fast convert string_view to floating point

The code makes following assumptions: std::string_view is not null-terminated there are no exponents, all floating point inputs are in the way 123.123 limiting ...
Nick's user avatar
  • 1,572
1 vote
0 answers
76 views

Python script that turns a gigantic text file into an IP geolocation database

I have written a Python script that turns a gigantic text file into a SQLite3 database. The text file is truly gigantic, it is 133MiB or 140,371,572 bytes in size, and contains 140,371,572 characters ...
Ξένη Γήινος's user avatar
5 votes
1 answer
596 views

Python script that identifies the country code of a given IP address

This is a Python script I wrote to identify the country code of a given IP address, using data obtained from tor. It uses geoip.txt to identify country code for IPv4 addresses, and geoip6.txt to do so ...
Ξένη Γήινος's user avatar
5 votes
1 answer
2k views

Convert bool to int and int to bool

I'm a noob. I wrote this code to convert bools to ints and ints to bools as a past-time but I would like to know whether to continue programming - this is the kind of thing I've been doing, no useful ...
user avatar
4 votes
1 answer
173 views

Fahrenheit <=> Celsius converter in Rust

It's one of the tasks suggested in the Rust Programming Language book by Steve Klabnik and Carol Nichols, and to a complete Rust newbie like me, figuring out converting scale from ...
szychy's user avatar
  • 141
6 votes
1 answer
168 views

General bytes to number converter (c++)

I've written a bytes to number converter for cpp similar to the python int.from_bytes. It does not make any assumptions on: The endianness of the input buffer The ...
Sam Coutteau's user avatar
1 vote
1 answer
1k views

Mapping pandas' Series to dataclasses

I've got something really simple this time where I'm mapping pandas' Series to dataclasses with a oneliner helper function (as ...
t3chb0t's user avatar
  • 44.2k
2 votes
3 answers
266 views

length unit converter

I'm trying to make a imperial/metric length unit converter in Python. Here is my full code: ...
Rozy0930's user avatar
3 votes
0 answers
105 views

Type coercion function (a "safe cast")

Usually in C++, the language rules automatically convert types as necessary. For example, I can pass a pointer-to-derived in place of a pointer-to-base, and the same with references. There are ...
Toby Speight's user avatar
  • 74.5k
3 votes
1 answer
346 views

Python script copying specific table data from multiple docx files into an XLS file

The code copies the second column from the right of all the docx files' tables from the folder where the py file is saved, and does some editing on the content in specific cases. The problem that it ...
Domi Szécskai's user avatar
4 votes
1 answer
545 views

C++ String Conversions using Iconv

Since charset conversions is so darn badly implemented and most standard options are deprecated I recently wrote a wrapper around iconv that converts from system narrow / multibyte character set to ...
rioki's user avatar
  • 462
3 votes
1 answer
139 views

An up-cast for C++

Usually in C++, the language rules automatically widen types as necessary. For example, I can pass a pointer-to-derived in place of a pointer-to-base, and the same with references. There are ...
Toby Speight's user avatar
  • 74.5k
5 votes
3 answers
712 views

Number System Conversions with strtol

Description The code uses strtol() to convert text that represents a value in a given base into an integer. It takes three arguments from the command line, ...
Harith's user avatar
  • 4,093
5 votes
1 answer
256 views

Function to format time, from seconds to a particular expresion

From an integer X representing a time duration in seconds produce a simplified string representation. For example, given X=100, you should output: "1m40s" Use the following abbreviations w,d,...
Leandro Tabak's user avatar
8 votes
1 answer
243 views

Convert integer to Roman numeral string

This is my 1st time developing PHP code and I am only 13 years old. I have experience in other programming languages like lua, python, and c++. This is a simple Number to Roman Numeral code I made for ...
Red Sebastian A. Arce's user avatar
3 votes
0 answers
81 views

Convert different address formats to German one

I would like to find out which address format is input and convert it to the German format. Examples: 5, Rue de l'exemple is luxembourgish. ...
Daniel's user avatar
  • 219
1 vote
0 answers
94 views

convert GPS coordinates to C-SQUARES, resolution 0.05°×0.05°

This is a simple C-Squares encoder in R. FYI, C-Squares is a geocoding algorithm that assigns GPS coordinates to a spatial grid with a chosen resolution. Its specifications is here: https://www.cmar....
simplyPTA's user avatar
  • 191
0 votes
3 answers
166 views

Convert from decimal to binary and octal

I wrote a program that implements an algorithm that converts from decimal to binary and octal Please criticize my implementation. What else can I do to improve? ...
Mike's user avatar
  • 299
0 votes
1 answer
2k views

Best way to convert the string with Byte sequence to Byte Array

We had a string with byte array (hexadecimal) sequence, like: ...
Igor's user avatar
  • 182
0 votes
2 answers
89 views

JSONtab library : A tool to reversibly convert between an arbitrarily deep nested object and a tabular format

Could the following code be improved in terms of clarity, performance, maintainability, best practices etc? JSONtab library A tool to reversibly convert between an arbitrarily deep nested object and a ...
user2309803's user avatar
1 vote
1 answer
892 views

Python IPv6 verifier, parser and converter

This is a simple Python 3 program that verifies whether a string is a valid IPv6 address or not, parses IPv6 address to its hexadecimal and decimal values, and converts an integer to IPv6 format. I am ...
Ξένη Γήινος's user avatar
3 votes
4 answers
650 views

Convert number 1-5 from its spelt-out form

I'm working with an API that for some strange reason returns star ratings as words, like FIVE,FOUR,THREE,TWO,ONE. As far as I can see, there's no way to just get ...
Sensanaty's user avatar
  • 175
3 votes
3 answers
743 views

Convert program arguments to std::wstring

Due to recent need I wrote a simple main function that has the goal to convert the C-style strings and arrays into a more STL-style. Then because I also had a need ...
BrainStone's user avatar
2 votes
3 answers
789 views

Convert string to integer and catch errors

I have attempted [and made one] function to convert string to integer and catch errors in pure c Working method The whole working method is present in code itself The header file The str2num.h here:- <...
Pear's user avatar
  • 77
4 votes
1 answer
1k views

Python 3 script to phonetically transliterate written English to Cyrillic and/or Greek

This is a Python 3 script I have written over three days that transliterates (not translating) English orthography written in Latin alphabet to the Cyrillic alphabet, the Greek alphabet or a mixed of ...
Ξένη Γήινος's user avatar
0 votes
2 answers
180 views

Python 3 integer seconds to date-time string convertor

I have written two functions that output a date-time string for any given non-negative integer. The integer is treated as representing total number of seconds in a given time period, the first ...
Ξένη Γήινος's user avatar
1 vote
1 answer
2k views

Python 3 arbitrary base converter and base36 encoder

This is a script that can convert any numerical value to any arbitrary radix representation and back, well, technically it can convert a number to any base, but because the output is a string ...
Ξένη Γήινος's user avatar
2 votes
1 answer
147 views

Is it good way to user dao when assembling dto to entity or not?

I have User entity that has relationship to other entities(Order,Profile) When I assemble entity from dto and back I need assemble order and profile entity too. User entity: ...
DozezQuest's user avatar
6 votes
1 answer
397 views

Assembler. Algorithm for incrementing a decimal number

I share an algorithm that I have written myself. It is useful for incrementing any digit of a decimal number. That way, a conversion to decimal is not necessary. Please excuse the mistakes. I am ...
FER31's user avatar
  • 63
2 votes
3 answers
923 views

Python binary, decimal, hexadecimal, IPv4, octal converter

This is a Python (3) script that converts numbers among 5 data formats: binary, decimal, hexadecimal and octal, it supports 16 conversions, that is, it can convert each of the five data formats to and ...
Ξένη Γήινος's user avatar
3 votes
1 answer
1k views

PowerShell script binary-decimal-hexadecimal-ipv4 convertor

This is a fully functional PowerShell script I wrote not long ago that converts data (numerical data) among 4 data formats: binary, decimal, hexadecimal and ipv4. It supports 12 conversions, it can ...
Ξένη Γήινος's user avatar
6 votes
4 answers
2k views

Bytes to binary conversion function

I created a quick function to convert n bytes into binary for my student. She is not on that level yet, but I think it would be best for her if my demonstrative ...
Edenia's user avatar
  • 1,548
6 votes
2 answers
617 views

Flatten JSON to string

The code below is a Python module to flatten JSON-like structure (nested dictionaries and lists) to a single string. It also provides partial result in the form of flat list of strings. This ...
pabouk - Ukraine stay strong's user avatar
1 vote
1 answer
101 views

convert .sav SPSS files into long or flat format CSVs

I'm a long standing PHP, JS, C#(Unity) dev looking to get outside objects and lower down. I've written a quick program to read binary data from a .sav file, and output the data section into CSV's in ...
E R Barratt's user avatar
1 vote
1 answer
193 views

Binary-Decimal-Hexadecimal converter

I'm a fairly new programmer and have been learning c++ for about 8 months now. I've written a program that can take either binary, hexadecimal, and decimal inputs and convert them to the other two ...
Axel Bozic's user avatar
2 votes
3 answers
270 views

ArrayDowncasters Implementation for Downcasting from System.Array to Array of Specific Type in C#

I am working with System.Array and I am trying to convert System.Array objects to array of specific type (such as ...
JimmyHu's user avatar
  • 4,382
3 votes
3 answers
2k views

PowerShell script to convert .reg files to PowerShell commands

This is a PowerShell script I wrote a while ago that converts Windows Registry files to PowerShell commands(New-Item, Remove-Item...
Ξένη Γήινος's user avatar
1 vote
1 answer
295 views

ConvertAll Methods Implementation for Jagged Arrays in C#

This is a follow-up question for ConvertAll Methods Implementation for Multidimensional Array in C# and ConvertAll Methods Implementation for Multidimensional Array in C# - follow-up. Besides the ...
JimmyHu's user avatar
  • 4,382
1 vote
1 answer
86 views

ConvertAll Methods Implementation for Multidimensional Array in C# - follow-up

This is a follow-up question for ConvertAll Methods Implementation for Multidimensional Array in C#. Thanks to aepot's answer and Olivier's answer. In order to match the usage of the build-in API <...
JimmyHu's user avatar
  • 4,382
9 votes
2 answers
586 views

ConvertAll Methods Implementation for Multidimensional Array in C#

I am trying to perform some conversions with multidimensional array in C# and I have checked the discussion ConvertAll and 2-dimensional arrays. I found that ...
JimmyHu's user avatar
  • 4,382
0 votes
2 answers
91 views

Format simple array in multidimensional

I have a simple array in PHP like this : ...
Lokomass's user avatar
5 votes
2 answers
3k views

Represent integer as binary in C

To practice my C, I've written a small function in C to display an integer as an 8-bit binary number. Please let me know how to improve this function, and other C-style coding conventions. Thanks! <...
Linny's user avatar
  • 10k
3 votes
1 answer
97 views

Integer to Roman Numeral conversion

As a little standard exercise, I wrote an integer to roman numerals converter in F03. The result looks already neat enough, for my standards, but I wonder whether it could be made snappier without ...
Luca Argenti's user avatar

1
2 3 4 5
8