Write a function called write_nums() that outputs the first positive n numbers to a txt file called nums.txt

I have to print first n positive numbers for ex if its first 10 positive numbers then the output should be as follows 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 it should print the first 10 numbers in 10 lines but my… Read More Write a function called write_nums() that outputs the first positive n numbers to a txt file called nums.txt

I'm looking for an approach where I can pass every single file from folder to open these files in binary mode

I have data in some files, and I want to check each file with my code. I was able to read a single file every time but I need to change the path every time in my code with the name of the respective file. I have a folder where the all files are located.… Read More I'm looking for an approach where I can pass every single file from folder to open these files in binary mode

NameError: name '__file__' is not defined , os.path.dirname(os.path.abspath(__file__))

I’m trying to use os.path.dirname(os.path.abspath(file)) for tracking my file txt but i don’t why its not working with me: import os print(os.getcwd()) # Get Working directory print(os.path.dirname(os.path.abspath(__file__))) file = open("Youness.txt") NameError: name ‘__file__’ is not defined. >Solution : There is a good chance that __ file __ is not defined because you execute your code… Read More NameError: name '__file__' is not defined , os.path.dirname(os.path.abspath(__file__))

Read from CSV File and Write that data in different format in txt file in PHP

I am reading from csv file and writing the data in txt file using the code below: $row = 1; $file = fopen("newfile.txt","w"); if (($handle = fopen("Last.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); $row++; $colOne = rtrim($data[0],"’"); echo $colOne . "\n" . $data[3] . "<br… Read More Read from CSV File and Write that data in different format in txt file in PHP

Implementing the cp command using read/write system calls

I am trying to implement the cp command only using read/write system calls. Here is my code: /** * cp file1 file 2 */ #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> int main(int argc, char *argv[]) { int errsv; char contents[1024]; int fd_read, fd_write; fd_read = open(argv[1], O_RDONLY); if (fd_read == -1) { errsv… Read More Implementing the cp command using read/write system calls