Usecase: Simple edit

Simple Edit in a px-file or a folder of px-files

library(tidyverse)
library(pxmake)

Replace contact information in an existing px-file

Say you have a px-file, you want to have other contact information, than in the present file.

On the filesystem youcan have a folder and subfolders, like:

statbank_s_path <- file.path("S:","STATBANK","bank2020","Databases") 

subject_path <- file.path(statbank_s_path,"Greenland","FI") 
  1. Convert present file to a px-object
  2. Set CONTACT to new information

This is simple as it is the same in all languages

fil <- file.path(subject_path,"FIXUDD.px")

old <- px(fil)

old %>% px_contact("Per Lyster, pely@stat.gl") %>% 
  px_save(file.path(subject_path,"FIXUDD.px"))

Or do it for all px-files in a folder, like this:

file.list <- list.files(path=file.path(subject_path),pattern="*.px")

for (fil in file.list) {
  old <- px(file.path(subject_path,fil))
  
  old %>%
    px_contact("Per Lyster, pely@stat.gl") %>%  
    px_save(file.path(subject_path, fil))  
}